Command Line Tools
dbmigrate exec
dbmigrate exec
Section titled “dbmigrate exec”Execute a specific database migration by version number.
Synopsis
Section titled “Synopsis”wheels dbmigrate exec version=<version>Alias: wheels db exec
Description
Section titled “Description”The dbmigrate exec command allows you to migrate to a specific version identified by its version number, regardless of the current migration state. This is useful for moving to any specific point in your migration history.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
version | string | Yes | Version to migrate to |
Examples
Section titled “Examples”Execute a specific migration
Section titled “Execute a specific migration”wheels dbmigrate exec version=20240115123456Migrate to version 0 (revert all migrations)
Section titled “Migrate to version 0 (revert all migrations)”wheels dbmigrate exec version=0Use Cases
Section titled “Use Cases”Migrating to a Specific Version
Section titled “Migrating to a Specific Version”Move to any point in migration history:
# Check current statuswheels dbmigrate info
# Migrate to specific versionwheels dbmigrate exec version=20240115123456Rolling Back to Previous Version
Section titled “Rolling Back to Previous Version”Move to an earlier migration state:
# Check migration historywheels dbmigrate info
# Go back to specific versionwheels dbmigrate exec version=20240101000000Reset Database
Section titled “Reset Database”Clear all migrations:
# Migrate to version 0wheels dbmigrate exec version=0
# Verify empty statewheels dbmigrate infoImportant Considerations
Section titled “Important Considerations”Migration Order
Section titled “Migration Order”Executing migrations out of order can cause issues if migrations have dependencies. Always ensure that any required preceding migrations have been run.
Version Tracking
Section titled “Version Tracking”The command updates the migration tracking table to reflect the execution status.
Best Practices
Section titled “Best Practices”- Check Dependencies: Ensure required migrations are already applied
- Test First: Run in development/testing before production
- Use Sparingly: Prefer normal migration flow with up/latest
- Document Usage: Record when and why specific executions were done
- Verify State: Check migration status before and after execution
Version Number Format
Section titled “Version Number Format”Migration versions are typically timestamps in the format:
YYYYMMDDHHmmss(e.g., 20240115123456)- Year: 2024
- Month: 01
- Day: 15
- Hour: 12
- Minute: 34
- Second: 56
- The command will migrate UP or DOWN to reach the specified version
- Version must be a valid migration version or 0 to reset all
- The migration file must exist in the migrations directory
- The command displays the migration progress message
- Both up() and down() methods should be defined in the migration
Related Commands
Section titled “Related Commands”wheels dbmigrate up- Run the next migrationwheels dbmigrate down- Rollback last migrationwheels dbmigrate latest- Run all pending migrationswheels dbmigrate info- View migration statuswheels dbmigrate create blank- Create a new migration