PhoenixKit.Migrations.Postgres.V201 (phoenix_kit v2.41.0)

Copy Markdown View Source

V201: A user's view preferences, per view.

phoenix_kit_user_view_prefs holds what one admin chose for one view — a table's columns and their order, and whatever else the view's owner keeps there (a sort, filters) — one row per (user_uuid, key). key names the view ("users", "catalogue.detail_items"); prefs is a JSON object of top-level fields, each written whole.

Until now the Users table and the website-access table kept ONE column list for the whole site in a setting, the catalogue kept its per-user choices inside phoenix_kit_users.custom_fields (written as a whole map from whatever copy of the user the page held), and CRM kept them in a table of its own. A row per view is written without touching the user's row, and a field is patched with prefs || new in the upsert itself, so two tabs changing different fields both keep their change.

PhoenixKit.Users.ViewPrefs is the read and write path. The FK is ON DELETE CASCADE: deleting a user takes their preferences with them. The unique index is the upsert's conflict target and, leading with user_uuid, also serves the FK.

Additive only; re-runnable.

Summary

Functions

Rolls V201 back: drops the table. Every saved view preference is lost.

Functions

down(opts)

Rolls V201 back: drops the table. Every saved view preference is lost.

up(opts)