Repository navigation
fix: schema-drift check compared against wrong table + stale Neon DB - #92
Merged
Merged
Conversation
…nd stale Neon DB Two independent bugs made the schema-drift workflow always fail: 1. collect.ts read migration history from drizzle.__drizzle_migrations, which only exists when 'drizzle-kit migrate' runs directly against a DB. Production applies migrations via the app's own applyCommittedMigrations() (app/lib/db/migrations.ts), which tracks them in public.__clawproxy_migrations instead. The check was comparing against a table that never existed in prod. 2. DRIFT_CHECK_DATABASE_URL (the GitHub secret) was configured against the old Neon database before PR #88 moved auth to Coolify's internal Postgres. Neon stopped receiving writes once that PR shipped, so the check was diffing against a frozen, pre-cutover snapshot -- it would never see the new auth_* tables regardless of what actually merged. Fixes: - collect.ts now reads public.__clawproxy_migrations (matches production's real migration tracking). - Added scripts/schema-drift/apply-migrations.ts + a new db:drift:seed-expected script that seeds the CI throwaway DB using the app's actual migrator, not drizzle-kit migrate, so both sides of the diff use the same mechanism. - Rotated DRIFT_CHECK_DATABASE_URL to a new least-privilege read-only role (clawproxy_drift_ro, SELECT-only) on the current Coolify clawproxy-postgres instance. Verified locally end-to-end against real production: ✓ production matches the migrated schema (50 columns, 21 indexes, 6 migrations)
Strix Security ReviewNo security issues found. Review summaryReviewed the schema-drift check fix, which corrects the migration-history table ( Updated for Reviewed by Strix |
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.
Two bugs, one always-red workflow
collect.tsread migration history fromdrizzle.__drizzle_migrations, which only exists whendrizzle-kit migrateruns directly. Production applies migrations via the app's ownapplyCommittedMigrations(), tracked inpublic.__clawproxy_migrations— a table drizzle-kit never touches. The check was querying a table that doesn't exist in prod's migration flow.DRIFT_CHECK_DATABASE_URLwas set up ~11h before PR feat: move auth to Coolify Postgres #88 (move auth to Coolify Postgres) merged, so it still pointed at the old Neon DB. Neon stopped receiving writes once the app cut over, so the check was permanently comparing against a frozen pre-cutover snapshot.Fix
collect.tsnow readspublic.__clawproxy_migrations.scripts/schema-drift/apply-migrations.ts+db:drift:seed-expectedseeds the CI throwaway DB using the app's real migrator, so both sides of the diff use the identical mechanism production uses.DRIFT_CHECK_DATABASE_URLto a new least-privilege read-only role (clawproxy_drift_ro, SELECT-only, no write access) on the current Coolifyclawproxy-postgresinstance, and made that DB briefly publicly reachable (was previously LAN-only) so GitHub Actions can reach it.Verified
Ran the full check locally against real production:
Test plan