Command Line Tools
dbmigrate reset
dbmigrate reset
Section titled “dbmigrate reset”Reset all database migrations by migrating to version 0.
Synopsis
Section titled “Synopsis”wheels dbmigrate resetDescription
Section titled “Description”The dbmigrate reset command resets your database by migrating to version 0, effectively rolling back all executed migrations. This is useful during development when you need to start fresh.
Parameters
Section titled “Parameters”None.
Examples
Section titled “Examples”Reset all migrations
Section titled “Reset all migrations”wheels dbmigrate resetThis will migrate the database to version 0, rolling back all migrations.
Use Cases
Section titled “Use Cases”Fresh Development Database
Section titled “Fresh Development Database”Start with a clean slate during development:
# Reset all migrationswheels dbmigrate reset
# Re-run all migrationswheels dbmigrate latest
# Seed with test datawheels db seedTesting Migration Sequence
Section titled “Testing Migration Sequence”Verify that all migrations run correctly from scratch:
# Reset all migrationswheels dbmigrate reset
# Run migrations one by one to testwheels dbmigrate upwheels dbmigrate up# ... continue as neededFixing Migration Order Issues
Section titled “Fixing Migration Order Issues”When migrations have dependency problems:
# Reset all migrationswheels dbmigrate reset
# Manually fix migration files# Re-run all migrationswheels dbmigrate latestContinuous Integration Setup
Section titled “Continuous Integration Setup”Reset database for each test run:
# CI scriptwheels dbmigrate resetwheels dbmigrate latestwheels test runImportant Warnings
Section titled “Important Warnings”Data Loss
Section titled “Data Loss”WARNING: This command will result in complete data loss as it rolls back all migrations. Always ensure you have proper backups before running this command, especially in production environments.
Production Usage
Section titled “Production Usage”Using this command in production is strongly discouraged. If you must use it in production:
- Take a complete database backup
- Put the application in maintenance mode
- Have a rollback plan ready
Migration Dependencies
Section titled “Migration Dependencies”The reset process rolls back migrations in reverse chronological order. Ensure all your down() methods are properly implemented.
Best Practices
Section titled “Best Practices”- Development Only: Primarily use this command in development environments
- Backup First: Always backup your database before resetting
- Test Down Methods: Ensure all migrations have working down() methods
- Document Usage: If used in production, document when and why
Process Flow
Section titled “Process Flow”- Displays “Resetting Database Schema”
- Executes
dbmigrate exec version=0 - Automatically runs
dbmigrate infoto show the reset status
- The command will fail if any migration’s down() method fails
- Migration files must still exist for rollback to work
- The migration tracking table itself is preserved
- Use
wheels dbmigrate infoafter reset to verify status
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 db seed- Seed the database with data