Running Migrations
Once you’ve created migrations, you need to run them to apply changes to your database. This guide covers everything about executing and managing migrations.
Understanding Migration Execution
Section titled “Understanding Migration Execution”What Happens When You Run Migrations
Section titled “What Happens When You Run Migrations”-
Check Migration History
- Reads which migrations have already run
- Stored in a
migrationstable in your database
-
Find Pending Migrations
- Compares created migrations with migration history
- Identifies which haven’t run yet
-
Run Pending Migrations
- Runs in timestamp order (oldest first)
- Records completion in migration history
-
Update Database
- Your database schema is now updated
- Ready to use with your models
Basic Migration Commands
Section titled “Basic Migration Commands”Running All Pending Migrations
Section titled “Running All Pending Migrations”st db:migrateor
stratus-ts db:migrateWhat it does:
- Runs all migrations that haven’t been executed yet
- Runs them in chronological order
- Stops if any migration fails
Next Steps
Section titled “Next Steps”Now that you can run migrations:
- Models - Use your migrated database schema
- Controllers - Build features with your database
- Database Setup - Configure advanced database options *
Documentation Notice:
The majority of this documentation was created with assistance from Claude (Anthropic AI) and refined with modifications by Rahul Roy, the project owner. We believe in transparency about our development process.