Skip to content

feat: Migrate from custom migrations to goose#11

Merged
eshaffer321 merged 3 commits intomainfrom
feat/goose-migrations
Jan 3, 2026
Merged

feat: Migrate from custom migrations to goose#11
eshaffer321 merged 3 commits intomainfrom
feat/goose-migrations

Conversation

@eshaffer321
Copy link
Owner

Summary

  • Replace custom migration system with goose library for better maintainability
  • Convert 6 existing migrations to SQL files
  • Add bridge migration to handle transition from legacy system
  • Preserve all existing data during migration

Key Changes

  • Add github.com/pressly/goose/v3 dependency
  • Create SQL migration files in internal/infrastructure/storage/migrations/
  • Add Go bridge migration (00007) for legacy system detection
  • Update Storage to use goose with embedded migrations

Safety Features

  • Existing databases: Legacy schema_migrations versions are copied to goose_db_version before goose runs, preventing re-execution
  • Fresh databases: All 7 migrations run normally
  • Data preserved: All existing records remain untouched

Test plan

  • All unit tests pass (go test ./...)
  • Migration tests verify fresh database creation
  • Migration tests verify idempotency (running twice works)
  • Manual testing: Migrated existing production database successfully
  • Manual testing: API returns data correctly after migration
  • CI passes (Go lint, test, build, security)
  • Playwright E2E tests pass

@eshaffer321 eshaffer321 closed this Jan 3, 2026
@eshaffer321 eshaffer321 reopened this Jan 3, 2026
@eshaffer321 eshaffer321 force-pushed the feat/goose-migrations branch from cb2a08e to 3e65804 Compare January 3, 2026 00:18
- Remove accidentally committed monarch_sync.db.backup
- Add *.db.backup pattern to .gitignore
Replace the custom migration system with goose library for better
maintainability and future seeding support.

Key changes:
- Add goose v3 dependency for SQL and Go migrations
- Convert 6 existing migrations to SQL files in migrations/ directory
- Add bridge migration (00007) that handles transition from old system
- Detect legacy schema_migrations table and preserve version history
- Update tests to verify goose migration behavior

Safety features:
- Existing databases: Legacy versions are copied to goose_db_version
  before goose runs, preventing re-execution of already-applied migrations
- Fresh databases: All 7 migrations run normally
- All existing data is preserved during the transition

Benefits:
- CLI tools: goose up, goose down, goose status
- SQL migrations: Easier to write and review
- Seeding support: goose -no-versioning for test data
- Down migrations: Proper rollback support
@eshaffer321 eshaffer321 force-pushed the feat/goose-migrations branch from 3e65804 to 5d8d799 Compare January 3, 2026 00:21
@eshaffer321 eshaffer321 merged commit 189a6da into main Jan 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant