wheels dbmigrate reset
Reset all database migrations by rolling back all executed migrations and optionally re-running them.
Synopsis
Description
The dbmigrate reset
command provides a way to completely reset your database migrations. It rolls back all executed migrations in reverse order and can optionally re-run them all. This is particularly useful during development when you need to start fresh or when testing migration sequences.
Options
--env
--env
Type: String
Default:
development
Description: The environment to reset migrations in
--datasource
--datasource
Type: String
Default: Application default
Description: Specify a custom datasource for the reset
--remigrate
--remigrate
Type: Boolean
Default:
false
Description: After rolling back all migrations, run them all again
--verbose
--verbose
Type: Boolean
Default:
false
Description: Display detailed output during reset
--force
--force
Type: Boolean
Default:
false
Description: Skip confirmation prompts (use with caution)
--dry-run
--dry-run
Type: Boolean
Default:
false
Description: Preview the reset without executing it
Examples
Reset all migrations (rollback only)
Reset and re-run all migrations
Reset in testing environment with verbose output
Force reset without confirmation
Preview reset operation
Use Cases
Fresh Development Database
Start with a clean slate during development:
Testing Migration Sequence
Verify that all migrations run correctly from scratch:
Fixing Migration Order Issues
When migrations have dependency problems:
Continuous Integration Setup
Reset database for each test run:
Important Warnings
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
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
Use the confirmation prompts (don't use --force)
Have a rollback plan ready
Migration Dependencies
The reset process rolls back migrations in reverse chronological order. Ensure all your down() methods are properly implemented.
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
Use Confirmation: Don't use --force unless in automated environments
Document Usage: If used in production, document when and why
Process Flow
Confirms the operation (unless --force is used)
Retrieves all executed migrations
Rolls back each migration in reverse order
Clears the migration tracking table
If --remigrate is specified, runs all migrations again
Notes
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 info
after reset to verify status
Related Commands
Last updated
Was this helpful?