This project includes a separate migration container that gives you full control over when database migrations run.
- Migration Container: The project uses a dedicated migration container built from
Dockerfile.migrate - Migration Tool: Uses the bun migration tool located in
apps/server/cmd/bun/ - Separate Control: Migrations run in their own container, separate from the application server
- Server Dependency: The server waits for migrations to complete successfully before starting
If you need to run migrations manually outside of Docker:
-
Build the bun migration tool:
cd apps/server go build -o bun ./cmd/bun -
Run migrations:
./bun db migrate
-
Check migration status:
./bun db status
-
Rollback last migration:
./bun db rollback
For creating new migrations, use the bun tool:
-
Build the bun tool:
cd apps/server go build -o bun ./cmd/bun -
Create new migration:
./bun db create_tx_sql migration_name
Migrations are stored in apps/server/cmd/bun/migrations/ and follow the naming convention:
YYYYMMDDHHMMSS_description.tx.up.sql- Migration to applyYYYYMMDDHHMMSS_description.tx.down.sql- Migration to rollback
- Image: Built from
apps/server/infra/Dockerfile.migrate - Tool: Uses bun migration tool (
./bun db migrate) - Restart Policy:
no(runs once and exits) - Dependencies: Waits for database to be healthy before running
- Server Dependency: Server waits for migration container to complete successfully
The migration system supports:
- PostgreSQL (recommended)
- MySQL
- SQLite
The startup script automatically detects the database type and waits appropriately.