Uh oh!
There was an error while loading. Please reload this page.
V120: Document Creator Category → Type taxonomy migration - #545
Conversation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
timujinne
left a comment
There was a problem hiding this comment.
PR #545 Review — V120: Document Creator Category → Type taxonomy migration
V120 adds the schema foundation for the Document Creator's Category → Type hierarchy: two new tables, nullable FK columns on templates/documents, a data migration of legacy category strings, and the @current_version bump. The migration is well-structured, idempotent in the common single-schema case, correctly restores the ⚡ LATEST marker (V119 had lost it), and touches no maintainer-owned files. Two correctness issues should be addressed before merge.
Critical
None.
Major
v120.ex:33, v120.ex:53 — uuid primary key has no default. Both create table blocks declare add(:uuid, :uuid, primary_key: true) with no column default. Every other Document Creator table (v86.ex:22,42,90, v117.ex:54,103) declares the PK as add(:uuid, :uuid, primary_key: true, default: fragment("uuid_generate_v7()")). The Ecto schemas use autogenerate: true so app-level inserts work, but any raw INSERT (including future migrations) hits a NOT NULL violation on uuid. The migration's own data-migration block sidesteps this by computing new_uuid := uuid_generate_v7() explicitly — proof the table has no DB-level default. Add default: fragment("uuid_generate_v7()") to both PK columns for consistency and safety.
v120.ex:62-79, v120.ex:89-95 — information_schema.columns guards omit table_schema. The DO $$ existence checks filter only on table_name/column_name. PhoenixKit supports multi-prefix (multi-tenant) installs — that is what the prefix parameter is for — and V110, V112, V116, V119 all qualify these guards with WHERE table_schema = '#{schema}'. Without that filter, in a multi-schema install the guard sees the column (or its absence) in any schema: the ADD COLUMN and the data-migration IF EXISTS (... column = 'category') block can be skipped or run for the wrong prefix, silently leaving a tenant un-migrated. Add a schema binding and include table_schema = '#{schema}' in all three guards.
Minor
Data migration uses initcap, spec specifies an explicit map. Spec §4 step 4 says "financial" → "Financial", "technical" → "Technical", others "capitalized". initcap(legacy) matches for those two, but a multi-word legacy value like legal review becomes Legal Review rather than Legal review. Harmless if legacy values are single-word; otherwise consider an explicit CASE. Non-blocking.
v120.ex (down) — category re-added as varchar(255), original was unbounded VARCHAR. V117 created the column as VARCHAR (no length) on both tables (v117.ex:40, v117.ex:106). Down-migrations are best-effort and 255 is ample, but for an exact reversal use unbounded varchar.
Nitpick
postgres.exV120 doc section mixes###heading with#-prefixed comment lines, whereas V119/V118 use plain Markdown bullet lists under the heading. Cosmetic.- The
down/0path relies on Postgres auto-dropping the V117phoenix_kit_doc_templates_category_indexwhencategoryis dropped — acceptable, though a strict reversal would restore that index.
VERDICT: REQUEST CHANGES — the two Major items are genuine correctness risks (the table_schema one breaks multi-prefix installs). Both are small, localized fixes.
🤖 Review generated with Claude Code
…, exact legacy mapping
- Add `default: fragment("uuid_generate_v7()")` to both PK columns in
phoenix_kit_doc_categories and phoenix_kit_doc_types tables.
- Add `schema` binding (matching v119 pattern) and `AND table_schema = '#{schema}'`
to all three information_schema.columns guards in up/0 and the one in down/0.
- Replace initcap(legacy) with an explicit CASE map (financial/technical) falling
back to capitalize-first-letter for unknown values.
- Change down/0 ADD COLUMN varchar(255) to unbounded varchar on both templates
and presets, matching the V117 original definition.
- Align V120 doc section in postgres.ex to plain Markdown bullets (V118/V119 style).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>timujinne
commented
May 16, 2026
Review fixes applied — |
Trim the speculative "if presets should participate" line from the moduledoc Note — that decision belongs in the PR #545 review doc, not in durable migration documentation. Factual notes (presets excluded from the taxonomy, scope-index recreation) stay. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…edup
Post-merge fixes to the V120 migration (unreleased — no host app has run
migration 120, so editing in place rather than via a new version):
- Dropping phoenix_kit_doc_template_presets.category also dropped the V117
composite index (scope_type, scope_id, category). up/0 now recreates it on
(scope_type, scope_id); down/0 restores the original 3-column form.
- Data migration grouped legacy values by exact string, so case variants
('Financial'/'financial') produced duplicate Category rows. Now groups by
lower(category) and repoints templates case-insensitively.
- Dropped the redundant standalone [:category_uuid] index on doc_types
(covered by the [:category_uuid, :position] composite).
- Moduledoc notes presets do not join the taxonomy; their legacy category
strings are discarded (open question for the module developer).
Adds the PR BeamLabEU#545 review notes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>Complete the 1.7.112 entry to cover all unreleased work since v1.7.111: PR #548 (table_default sort/DnD, bulk_actions_bar, empty_state, sort_selector, form_section/form_actions, Reorder/Values/Format utils), PR #544 (MediaBrowser folder management overhaul), PR #545 (V120 document-creator taxonomy), PR #547/#542 (i18n manifests), and this session's post-merge cleanup. Re-dated to 2026-05-18. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
V120 — Document Creator Category → Type taxonomy
Adds migration V120, the schema/DB foundation for the Document
Creator's Category → Type hierarchy (module-side work is a separate PR
on
phoenix_kit_document_creator).What V120 does
phoenix_kit_doc_categoriesandphoenix_kit_doc_typestables (UUIDv7 PKs,
statussoft-delete,positionordering).category_uuid/type_uuidFK columns tophoenix_kit_doc_templatesandphoenix_kit_doc_documents(
ON DELETE SET NULL);doc_types.category_uuidisON DELETE CASCADE.template.categorystringbecomes a
Categoryrow; templates/documents are repointed via FK;the legacy
categorystring columns on templates and presets aredropped.
@current_versionto 120; idempotent up/down.Notes
uuid_generate_v7()for data-migrated rows, per houseconvention (consistent with the schema's UUIDv7 autogenerate).
CHANGELOG.md/@versionchanges — maintainer-owned.🤖 Generated with Claude Code