PhoenixKit.Migrations.Postgres.V192 (phoenix_kit v2.29.1)

Copy Markdown View Source

V192: Widen phoenix_kit_annotations_kind_check for the new "arrow" kind.

Etcher 0.13's single-arrow tool was exposed in the media viewer's toolbar (media_canvas_viewer.html.heex) without widening the CHECK constraint (or the schema's @kinds) to match — the THIRD time this exact regression has shipped, after "marker" (V130) and "image" (V157). Without this, drawing an arrow works, labelling it works, and the whole thing silently fails to persist across a reload — the changeset rejection is a [warning] in the log and nothing else.

Idempotent: each ADD CONSTRAINT is preceded by DROP CONSTRAINT IF EXISTS on the same prefixed table.

down/1 is conditional, by necessity

Rolling back re-adds the narrower CHECK, and Postgres validates every existing row when a CHECK is added. So the rollback is only possible while no kind = 'arrow' annotation exists — once a user has drawn one, the old constraint is not a truthful description of the data and there is no correct way for a schema migration to assert it.

down/1 therefore checks first and raises a message naming the row count and the two ways forward, rather than letting the ALTER fail with an opaque 23514 mid-rollback. The alternatives were both worse: deleting or rewriting user annotations is data loss a rollback has no business performing, and NOT VALID would leave a constraint that lies about the rows already in the table.

Summary

Functions

down(opts)

up(opts)