Repository navigation
feat: migrate with the admin app, check schema.ts for drift - #2174
Merged
Merged
Conversation
The admin app (graasp/graasp-web) now owns the database schema (ADR 0002, graasp/graasp-web#305). Core stops running drizzle migrations. - `mise run migrate` runs admin's migrations, from the commit pinned as ADMIN_REF in mise.toml, against DB_CONNECTION. - CI migrates its test databases with admin and replaces migration-check with `mise run schema-drift-check`, which compares schema.ts with the migrated database. - schema.ts catches up with production: admin columns and indexes, the apps.thumbnail default, the real names of two constraints and an opclass. - The drizzle migrate image is no longer built.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Core side of graasp/graasp-web#305. Depends on graasp/graasp-web#309 (admin baseline migration).
Summary
The admin app now owns the database schema (ADR 0002 in graasp/graasp-web). Core stops running drizzle migrations: it migrates with admin, and
schema.tsbecomes a hand-maintained description checked against the migrated database.pushSchemafromdrizzle-kit/apiwould do this in one call, but in 0.31.11 it drops query parameters while introspecting.schema.tsnow matches the admin-migrated database:admins.name/languageand admin's 4itemindexes;apps.thumbnaildefault;publication_removal_noticescreator FK and themaintenancePK;enum_opsonitem_membership.permission;created_at DESC NULLS FIRST.mise run migrateworks locally too. It clones admin intotmp/admin; setADMIN_DIR=../adminto use your own checkout. jest and vitest now ignoretmp/.drizzle-kit migrate/generate/checkscripts are gone. The SQL files insrc/drizzle/stay as frozen history.Evidence
Run locally against a fresh database migrated by admin (graasp/graasp-web#309):
Drift check:
schema.tson main): 35 statements, includingALTER TABLE "admins" DROP COLUMN "name",DROP INDEX "idx_item_type_h5p_contentid"andALTER TABLE "maintenance" ADD CONSTRAINT "UQ_maintenance_slug" UNIQUE("slug").schema.ts matches the database, exit 0.The check still catches drift:
mise run checkpasses: prettier, tsc, and eslint with no errors.I couldn't run the e2e and vitest suites locally (no Redis). This PR's CI is their first run against an admin-migrated database.
Merge Danger
Door: two-way
Reverting restores drizzle migrations in CI and the migrate image build. No database is touched by merging.
Blast Radius: CI and deploys
ADMIN_REFfrom the PR-branch commit167dd63c3to a commit on admin'smain(or a release tag) once feat: add core schema baseline migration graasp-web#309 merges. A squash merge drops the branch commit.graasp-infrastructuredeploys still copy and rungraasp:migrate-*images. Dev keeps running the lastmigrate-nightly, which does nothing. A prod "Apply Migration" for a new version would fail: no image is published for it. I'm switching those workflows to admin'sAdmin.Release.migrate()in a separate PR.docker/compose.ymlstill ships the old drizzle migrate image, which doesn't know admin's migrations. Fixing that needs a public admin migrate image (follow-up).mise run migrate; mise installs Erlang and Elixir for admin.