Add a database migration
SupaCloud uses sequential, numbered SQL migrations in server/migrations/.
-
Find the next number — safely. Migration numbers are a shared namespace across parallel developers and worktrees. Before picking a number:
Terminal window git fetchls server/migrations/ # scan the highest number on mainAlso scan any sibling worktrees. Then take the next free number.
-
Add the file as
NNN_short_description.sqlinserver/migrations/. -
Keep closed CHECK vocabularies executable. If a migration renames a stored value to one the old
CHECK (... IN (...))does not permit, use this exact sequence: DROP CHECK → UPDATE old rows → ADD CHECK. A deletion or a rewrite to a value already permitted by the old CHECK may happen before the narrowing CHECK. The committed guard catches the unsafe rename order:Terminal window python3 scripts/check-migration-check-order.py --self-testpython3 scripts/check-migration-check-order.pyAdd a seeded upgrade test whenever rows can carry the old value; an empty database cannot expose this class of failure.
-
Verify it applies and the server still type-checks:
Terminal window cd server && cargo check