feat: add automated migrations to deployment pipeline#144
Closed
jakebromberg wants to merge 5 commits intomainfrom
Closed
feat: add automated migrations to deployment pipeline#144jakebromberg wants to merge 5 commits intomainfrom
jakebromberg wants to merge 5 commits intomainfrom
Conversation
added 5 commits
February 1, 2026 22:56
Add roster resource to access control statements. Add roster write permission to stationManager role. Add new admin role with full permissions including roster management.
Refactor email system to use discriminated union pattern with unified sendEmail() function. Add accountSetup email type that sends a "Welcome! Set up your password" message to new users created by admin. The sendResetPassword callback now detects new users (empty realName) and sends accountSetup email instead of passwordReset email. - Add WXYCEmail discriminated union type - Add sendEmail() function with getEmailContent() factory - Add accountSetup email type with welcome messaging - Update sendResetPassword to detect new vs existing users - Add comprehensive unit tests for all email types
- Add capabilities text[] column to auth_user table - Include capabilities in JWT payload via definePayload - Register capabilities as Better Auth additionalField - Add unit tests for capability storage and JWT structure
- Add database indexes for frequently-queried columns: - flowsheet: show_id, album_id, rotation_id - show_djs: composite (show_id, dj_id) and dj_id - bins: dj_id, album_id - Add migration infrastructure to CI/CD: - Dockerfile.migrate for running drizzle-kit migrations - run-migrations GitHub Action - Migration jobs in deploy-base.yml workflow - Migrations tagged by count (e.g., migrate:0028) - Fix orphaned migration file: - Rename 0024_anonymous_devices.sql to 0028 - Add missing journal entry and snapshots
Add comprehensive migration testing infrastructure: - Static analysis (lint-migrations.js): Detects dangerous patterns like missing CONCURRENTLY, NOT NULL without DEFAULT, missing IF NOT EXISTS guards, and destructive operations - Rollback generator (generate-rollback.mjs): Auto-generates rollback SQL scripts from migrations with risk assessment and data loss warnings - Runtime estimation (estimate-migration.mjs): Estimates migration duration based on table sizes and operation types - Snapshot testing scripts: Create, load, and test migrations against production-like schema snapshots - Weekly CI workflow (migration-snapshot-test.yml): Automated testing against production snapshots every Sunday - CI integration: Added migration linting to PR checks Includes rollback files for migrations 0000-0028.
This was referenced Feb 12, 2026
Member
Author
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
Changes
Migration Testing Tools (New)
Added infrastructure to catch migration issues before production deployment:
lint-migrations.jsgenerate-rollback.mjsestimate-migration.mjscreate-schema-snapshot.mjsload-schema-snapshot.mjstest-migrations-snapshot.mjsLint Rules:
concurrent-index: Warns when CREATE INDEX misses CONCURRENTLYnot-null-no-default: Blocks ADD COLUMN NOT NULL without DEFAULTmissing-if-not-exists: Warns about missing idempotency guardsdangerous-ops: Blocks TRUNCATE, DROP TABLE without IF EXISTSCI Integration:
shared/npm Scripts:
Database Indexes
Added B-tree indexes to improve query performance:
flowsheetflowsheet_show_id_idxshow_idflowsheetflowsheet_album_id_idxalbum_idflowsheetflowsheet_rotation_id_idxrotation_idshow_djsshow_djs_show_id_dj_id_idx(show_id, dj_id)show_djsshow_djs_dj_id_idxdj_idbinsbins_dj_id_idxdj_idbinsbins_album_id_idxalbum_idDeployment Pipeline
Added migration jobs to the deployment workflow:
flowchart TB subgraph setup[Setup] A[Detect targets] --> B[Detect migration version] end subgraph build_phase[Build Phase] C[build-migrate] --> D[Build migrate:NNNN image] E[build] --> F[Build app images] end subgraph deploy_phase[Deploy Phase] G[migrate] --> H[Run migrations on EC2] H --> I[deploy] I --> J[Deploy app containers] end setup --> build_phase build_phase --> deploy_phaseMigration versioning: Images are tagged with the highest migration number (e.g.,
migrate:0028), providing traceability without manual version management.Migration Fixes
0024_anonymous_devices.sql→0028_anonymous_devices.sql0027_add-performance-indexes.sqlto contain only index definitionsNew Files
Dockerfile.migrate.github/actions/run-migrations/action.yml.github/workflows/migration-snapshot-test.ymlscripts/lint-migrations.jsscripts/generate-rollback.mjsscripts/estimate-migration.mjsscripts/*-snapshot.mjsshared/database/src/migrations/rollbacks/Test plan
Dockerfile.migratebuilds locallynpm run lint:migrationsto verify linter worksnpm run migration:estimate 0027_add-performance-indexes.sqlNotes
Migrations are already tested in CI via
init-db.mjswhich runsnpm run drizzle:migrateduring test environment setup. Any PR that modifiesshared/**(including migrations) triggers integration tests.