wheels db reset
Reset the database by dropping it and recreating it from scratch.
Synopsis
wheels db reset [--datasource=<name>] [--environment=<env>] [--force] [--skip-seed] [--seed-count=<n>]
Description
The wheels db reset
command completely rebuilds your database by executing four operations in sequence:
Drops the existing database (
wheels db drop
)Creates a new database (
wheels db create
)Runs all migrations (
wheels dbmigrate latest
)Seeds the database with sample data (
wheels db seed
)
This is a destructive operation that will delete all existing data.
Options
--datasource=
Specify which datasource to use. If not provided, uses the default datasource from your Wheels configuration.
wheels db reset --datasource=myapp_dev
--environment=
Specify the environment to use. Defaults to the current environment.
wheels db reset --environment=testing
--force
Skip the confirmation prompt. Use with caution!
wheels db reset --force
--skip-seed
Skip the database seeding step.
wheels db reset --skip-seed
--seed-count=
Number of records to generate per model when seeding. Defaults to 5.
wheels db reset --seed-count=20
Examples
Basic Usage
Reset with confirmation:
wheels db reset
# Will prompt: Are you sure you want to reset the database? Type 'yes' to confirm:
Force Reset
Reset without confirmation:
wheels db reset --force
Reset Test Database
wheels db reset --datasource=myapp_test --environment=testing --force
Reset Without Seeding
wheels db reset --skip-seed --force
Safety Features
Confirmation Required: Must type "yes" to confirm (unless --force)
Production Warning: Extra warning for production environment
Special Production Confirmation: Must type "reset production database" for production
Warning
This operation is irreversible! All data will be permanently lost.
Common Use Cases
Development Reset
# When you need a fresh start
wheels db reset --force --seed-count=50
Before Major Changes
# Backup first
wheels db dump --output=backup-before-reset.sql
# Then reset
wheels db reset
Automated Testing
# In test scripts
wheels db reset --environment=testing --force --skip-seed
What Happens
Drop Database
All tables and data are deleted
Database is completely removed
Create Database
Fresh database is created
Character set and collation are set (MySQL)
Run Migrations
All migrations run from scratch
Schema is recreated
Seed Database (unless --skip-seed)
Sample data is generated
Useful for development/testing
Error Recovery
If reset fails partway through:
# Manual recovery steps
wheels db drop --force # Ensure old database is gone
wheels db create # Create new database
wheels dbmigrate latest # Run migrations
wheels db seed # Seed data (optional)
Best Practices
Always backup production data first
Use --force only in automated scripts
Avoid resetting production databases
Use db setup for new databases instead
Related Commands
wheels db setup
- Setup new database (non-destructive)wheels db drop
- Just drop databasewheels db dump
- Backup before resetwheels dbmigrate reset
- Reset just migrations
Last updated
Was this helpful?