Skip to content

app/: one initial schema migration in place of twelve (sc-8900) - #107

Merged
ndbroadbent merged 1 commit into
mainfrom
app-squash-migrations
Dec 3, 2026
Merged

ndbroadbent merged 1 commit into
mainfrom
app-squash-migrations

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

app/ starts production on a fresh database at cutover, so its twelve migrations become one, app/database/migrations/0001_01_01_000000_initial_schema.rs. It builds the schema the twelve leave behind.

What's in it

  • The schema builder creates users, sessions, the cache and queue tables (written out in place of laravel::cache::tables!() and laravel::queue::tables!()), identities, user_tokens, waitlist and project_tokens. The columns the later ALTERs added to users (the email choices, signup_notified_at, heard_about_*) are now part of the CREATE, still last.
  • Raw SQL creates the domain tables, as before: the old domain migration plus the columns added to it later, each placed last in its table as the ALTERs left them (blobs.deleting, diffs.used_at, projects.gallery_urls and comment_when_unchanged, renders.uploads and used_at), with their indexes. It also creates gallery_purge_failures, emails, invitations and device_logins, and the effective_snapshots view. The comments that explained each column stay as SQL comments.
  • The schema builder can't make timestamp with time zone. So users.signup_notified_at is declared through the builder and then changed to timestamptz by one statement at the top of the SQL, before any row exists. The builder now adds project_tokens' foreign key to projects, under its old name project_tokens_project_id_fkey.
  • docs/design-storage.md links to the new file. tests/scaffold.rs doesn't name any migration file, so it's unchanged.

The two schemas are identical
On agents-build-2: two postgres:17 containers. One was migrated by the binary built with origin/main's twelve migrations, the other by the binary built with this file (visualci-app migrate --force; both runs include oauth-provider-laravel's four migrations). Then each was dumped:

pg_dump -U visualci --schema-only --no-owner --no-privileges visualci > old.sql   # and new.sql
grep -v '^\\\(un\)\?restrict ' old.sql > old.norm.sql                          # and new
diff -u old.norm.sql new.norm.sql

Result: empty (3,464 lines each). The raw diff old.sql new.sql differs only in the two \restrict / \unrestrict lines: pg_dump 17 writes a random key there on every run. Column order wasn't normalised. The columns the ALTERs added stay last, so the dumps match byte for byte.

Checks (app/, on agents-build-2, with postgres:17 and rustfs/rustfs:1.0.6 on 59000): cargo fmt --check passes. cargo clippy --locked --all-targets -- -D warnings passes. cargo test --locked: 199 passed, 0 failed, 0 ignored.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@ndbroadbent
ndbroadbent force-pushed the app-squash-migrations branch from 9086a11 to 6e5cc45 Compare December 3, 2026 03:46
@ndbroadbent
ndbroadbent merged commit 1fa307b into main Dec 3, 2026
12 checks passed
@ndbroadbent
ndbroadbent deleted the app-squash-migrations branch December 3, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant