PhoenixKit.Migrations.Postgres.V217 (phoenix_kit v2.62.2)

Copy Markdown View Source

V217: the options of a rendition, in one JSON object.

A rendition (phoenix_kit_storage_dimensions) had a column for each setting that came later: crop_mode (V210), fit_by (V211), shape (V214), and every new one would have meant another migration. V217 adds options (jsonb, NOT NULL, default {}), loaded as PhoenixKit.Modules.Storage.DimensionOptions, so a new option is a field in that struct and nothing else.

What the migration does:

  • adds options;
  • copies crop_mode, fit_by and shape into it;
  • sets keep_hdr (a photo's HDR gain map is kept in this size, Storage.HdrResize) for the standard medium and large of every set, which is what they did before it was a setting, and for no other size;
  • empties the three columns (they become nullable and lose their default, so nothing writes them again). Nothing reads them from this release on; they are kept, empty, for a few releases so the change can be backed out, and dropped by a later migration.

No rendition is remade: the options do not change what a size looks like (they are not part of its spec hash).

The copy and the emptying run only on rows that still hold their old values, so running V217 again changes nothing.

Locks

ADD COLUMN … NOT NULL DEFAULT '{}' with a constant default (no rewrite), then updates of a few dozen rows and DROP NOT NULL / DROP DEFAULT on the three columns (catalog changes only). Re-runnable.

Summary

Functions

Rolls V217 back: the three columns get their values and rules back, options goes.

Functions

down(opts)

Rolls V217 back: the three columns get their values and rules back, options goes.