feat(db): add node-pg-migrate for reversible database migrations#2
Merged
feat(db): add node-pg-migrate for reversible database migrations#2
Conversation
Replace static supabase/schema.sql with proper migration tooling: - Add node-pg-migrate with pg driver - Create initial migration with full up/down support - Add npm scripts: migrate:up, migrate:down, migrate:create, migrate:dry - Add DATABASE_URL to .env.example Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add migrate job to CI pipeline that runs after build+e2e pass. Only triggers on push to main (i.e. after PR merge). Requires DATABASE_URL secret in GitHub repo settings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Validates pending migrations against the live DB without executing them. Shows the SQL that would run, catching errors before merge. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace dry-run against prod with a proper isolated test: - Spin up Postgres 16 service container - Create auth schema stubs (auth.users, auth.uid()) - Run migrate up → down → up to verify full reversibility - No connection to production database on PRs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace Postgres + auth stubs with a real Supabase local instance: - Use supabase/setup-cli + supabase db start for full auth schema - Test up → down → up cycle to verify reversibility - Remove auth-stubs.sql (no longer needed) - migrate job on main now depends on migrate-check passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use supabase start (full stack) instead of db start for auth schema - Hardcode known local DB URL instead of parsing supabase status - Move prod migration deploy to separate workflow (triggers on migrations/** changes) - Remove "Run Migrations" job from CI to clean up PR graph Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Required by shared_links.share_token default value. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gen_random_bytes requires pgcrypto which isn't always available. gen_random_uuid() is built into Postgres 13+ and produces equivalent tokens. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
supabase/schema.sqlwith node-pg-migrate for proper versioned, reversible migrationsprofiles,saved_simulations,shared_linkstables with RLS policies and thehandle_new_usertriggermigrate:up,migrate:down,migrate:create,migrate:dryUsage
Verification
npm run checkpassesnpm testpasses (145 tests)npm run buildsucceedsNote
After merging, run
npm run migrate:upagainst the Supabase database to create tables and fix the "Database error saving new user" sign-in error.🤖 Generated with Claude Code