V117: Document composition — template category, document sections, template presets.
Three schema changes for the document composition feature:
ALTER
phoenix_kit_doc_templates— adds a nullablecategory :: varcharcolumn and an index on(category)for category-filtered queries.CREATE
phoenix_kit_doc_document_sections— join table between documents and templates for multi-section composed documents. Each row represents one template-backed section at a specific position within a document. Supports per-section variable overrides (variable_values) and image configuration (image_params). Positions are unique per document; deleting a document cascades to its sections. Nullifying a template FK on delete allows the section to survive template removal (content would need regeneration).CREATE
phoenix_kit_doc_template_presets— named, reusable compositions of template sections. Presets are scoped viascope_type+scope_id(e.g."organization"+ org uuid) and optionally categorized. ThesectionsJSONB column stores an ordered array of section descriptors ([%{template_uuid, position, variable_values, image_params}]).
All operations use IF NOT EXISTS guards so re-running up/1 on a
partially-applied schema is a no-op.
down/1 is destructive for the category column: dropping it deletes any
values users have assigned. The two new tables drop cleanly (re-running
up/1 recreates them empty), but column data is lost on rollback by
design — Ecto.Migration's rollback contract has no way to preserve it.