fix/db-migrations-in-app #49

Merged
YousifShkara merged 4 commits from fix/db-migrations-in-app into main 2026-05-30 04:06:12 +02:00
Owner
No description provided.
The deployment compose bind-mounted a postgres-init SQL script into the database container to pre-create the `mokosh_auth` schema. The Postgres container failed to start because the postgres user inside the container could not traverse the host-owned 0700 bind-mounted directory. The schema seeding also belonged in the application, not the database server.

Root cause was an ordering issue, not a missing schema: the host migrator (`migrations/`) runs before the auth migrator (`crates/mokosh-auth-storage/migrations/`), but host migration `005_oauth_client_metadata.sql` did `ALTER TABLE mokosh_auth.oauth_clients`, which needs both the schema and the table that the auth migrations create. The auth subsystem already creates the schema in its first migration (`20260506000001_create_schema.sql`), so the database-server seed was redundant once the host migration stopped touching the auth schema.

Relocate the column-add into the auth migrations as `20260515000001_alter_oauth_clients_launcher_metadata.sql` so it runs after `oauth_clients` exists (`20260506000003`). No host migration references `mokosh_auth` anymore, so the schema is created entirely by the application and the database-server bind mount is no longer needed. The host migrator already sets `ignore_missing(true)`, so existing databases that applied host version 5 keep working.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: David Randall <David@NiceGuyIT.biz>
Signed-off-by: David Randall <David@NiceGuyIT.biz>
WIP: Build on every push
All checks were successful
Build OCI container / Build and push mokosh-api image (push) Successful in 5m44s
Create release / Create release from merged PR (pull_request) Has been skipped
Check / fmt + clippy + compile + tests (pull_request) Successful in 28s
0c9a066d99
Signed-off-by: David Randall <David@NiceGuyIT.biz>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!49
No description provided.