Skip to content

Command Line Tools

dbmigrate reset

Reset all database migrations by migrating to version 0.

Terminal window
wheels dbmigrate reset

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.

None.

Terminal window
wheels dbmigrate reset

This will migrate the database to version 0, rolling back all migrations.

Start with a clean slate during development:

Terminal window
# Reset all migrations
wheels dbmigrate reset
# Re-run all migrations
wheels dbmigrate latest
# Seed with test data
wheels db seed

Verify that all migrations run correctly from scratch:

Terminal window
# Reset all migrations
wheels dbmigrate reset
# Run migrations one by one to test
wheels dbmigrate up
wheels dbmigrate up
# ... continue as needed

When migrations have dependency problems:

Terminal window
# Reset all migrations
wheels dbmigrate reset
# Manually fix migration files
# Re-run all migrations
wheels dbmigrate latest

Reset database for each test run:

Terminal window
# CI script
wheels dbmigrate reset
wheels dbmigrate latest
wheels test run

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.

Using this command in production is strongly discouraged. If you must use it in production:

  1. Take a complete database backup
  2. Put the application in maintenance mode
  3. Have a rollback plan ready

The reset process rolls back migrations in reverse chronological order. Ensure all your down() methods are properly implemented.

  1. Development Only: Primarily use this command in development environments
  2. Backup First: Always backup your database before resetting
  3. Test Down Methods: Ensure all migrations have working down() methods
  4. Document Usage: If used in production, document when and why
  1. Displays “Resetting Database Schema”
  2. Executes dbmigrate exec version=0
  3. Automatically runs dbmigrate info to 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 info after reset to verify status