V203: storage libraries, user libraries (phase 2 of
dev_docs/plans/2026-09-22-storage-libraries.md).
phoenix_kit_storage_library_members— who else may use a user library, and as what (manager|contributor|viewer). The owner is the library'sowner_uuid, never a member row. A member row goes with its library and with its user.- Deleting a user no longer deletes their files. The uploader FK
fk_files_user_uuidmoves fromON DELETE CASCADEtoSET NULL, andphoenix_kit_files_user_or_parent_checkaccepts a file that has a library instead (every file has one since V202). Their uploads in the site's libraries and in other people's stay, with no uploader. The media-folder creator FK moves toSET NULLtoo: with noON DELETEit refused to delete anyone who had ever created a folder. - A user's own libraries must be trashed before the user goes. The
library owner FK moves from
RESTRICTtoSET NULL, and the owner check allows a user library without an owner only once it is trashed. Deleting a user whose live library still names them fails on that check, so the stepAuth.delete_user/2takes first (trash every library they own) cannot be skipped, and a trashed library outlives its owner until the purge job empties it. - The library slug statements again, from V202 (#871): a database that
ran an earlier build of V202 is marked 202 without the
slugcolumn. They are idempotent, so everywhere else they change nothing.
Deliberately NOT here: dedup per library needs no schema change. A file
in a library other than Media gets a user_file_checksum that folds the
library in, so the existing unique index already holds one copy per
uploader per library, and Media's keys are the ones every existing row
has (Storage.user_file_checksum/3). V200's user-keyed capture-date
index stays (the schema manifest cannot say "removed in version N" yet).
Locks
Every FK and CHECK is replaced only while it still has its old shape, so
a re-run changes nothing. The new one is added NOT VALID under a
temporary name, validated in a statement of its own (a SHARE UPDATE EXCLUSIVE scan: reads and writes go on), and then swapped in for the old
one. Each validation scans its table once.
Re-runnable.
Summary
Functions
Rolls V203 back: drops the members table and puts the uploader, folder creator and library owner FKs and their checks back as V202 had them. Files whose uploader has been deleted since cannot satisfy the old check; the rollback refuses (the CHECK fails) rather than delete them. The slug stays — it is V202's.
Functions
Rolls V203 back: drops the members table and puts the uploader, folder creator and library owner FKs and their checks back as V202 had them. Files whose uploader has been deleted since cannot satisfy the old check; the rollback refuses (the CHECK fails) rather than delete them. The slug stays — it is V202's.