LogoLogo
HomeAPIBlog
3.0.0-SNAPSHOT
3.0.0-SNAPSHOT
  • INTRODUCTION
    • Getting Started
      • Running Local Development Servers
      • Beginner Tutorial: Hello World
      • Beginner Tutorial: Hello Database
      • Tutorial: Wheels, AJAX, and You
    • Frameworks and Wheels
    • Requirements
    • Manual Installation
    • Upgrading
    • Screencasts
  • Command Line Tools
    • CLI Overview
    • Quick Start Guide
    • Command Reference
      • Core Commands
        • wheels init
        • wheels info
        • wheels reload
        • wheels deps
        • wheels destroy
        • wheels watch
      • Code Generation
        • wheels generate app
        • wheels generate app-wizard
        • wheels generate controller
        • wheels generate model
        • wheels generate view
        • wheels generate property
        • wheels generate route
        • wheels generate resource
        • wheels generate api-resource
        • wheels generate frontend
        • wheels generate test
        • wheels generate snippets
        • wheels scaffold
      • Database Commands
        • wheels dbmigrate info
        • wheels dbmigrate latest
        • wheels dbmigrate up
        • wheels dbmigrate down
        • wheels dbmigrate reset
        • wheels dbmigrate exec
        • wheels dbmigrate create blank
        • wheels dbmigrate create table
        • wheels dbmigrate create column
        • wheels dbmigrate remove table
        • wheels db schema
        • wheels db seed
      • Testing Commands
        • wheels test
        • wheels test run
        • wheels test coverage
        • wheels test debug
      • Configuration Commands
        • wheels config list
        • wheels config set
        • wheels config env
      • Environment Management
        • wheels env
        • wheels env setup
        • wheels env list
        • wheels env switch
      • Plugin Management
        • wheels plugins
        • wheels plugins list
        • wheels plugins install
        • wheels plugins remove
      • Code Analysis
        • wheels analyze
        • wheels analyze code
        • wheels analyze performance
        • wheels analyze security
      • Security Commands
        • wheels security
        • wheels security scan
      • Performance Commands
        • wheels optimize
        • wheels optimize performance
      • Documentation Commands
        • wheels docs
        • wheels docs generate
        • wheels docs serve
      • CI/CD Commands
        • wheels ci init
      • Docker Commands
        • wheels docker init
        • wheels docker deploy
      • Deployment Commands
        • wheels deploy
        • wheels deploy audit
        • wheels deploy exec
        • wheels deploy hooks
        • wheels deploy init
        • wheels deploy lock
        • wheels deploy logs
        • wheels deploy proxy
        • wheels deploy push
        • wheels deploy rollback
        • wheels deploy secrets
        • wheels deploy setup
        • wheels deploy status
        • wheels deploy stop
    • CLI Development Guides
      • Creating Commands
      • Service Architecture
      • Migrations Guide
      • Testing Guide
  • Working with Wheels
    • Conventions
    • Configuration and Defaults
    • Directory Structure
    • Switching Environments
    • Testing Your Application
    • Using the Test Environment
    • Contributing to Wheels
    • Submitting Pull Requests
    • Documenting your Code
  • Handling Requests with Controllers
    • Request Handling
    • Rendering Content
    • Redirecting Users
    • Sending Files
    • Sending Email
    • Responding with Multiple Formats
    • Using the Flash
    • Using Filters
    • Verification
    • Event Handlers
    • Routing
    • URL Rewriting
      • Apache
      • IIS
      • Tomcat
      • Nginx
    • Obfuscating URLs
    • Caching
    • Nesting Controllers
    • CORS Requests
  • Displaying Views to Users
    • Pages
    • Partials
    • Linking Pages
    • Layouts
    • Form Helpers and Showing Errors
    • Displaying Links for Pagination
    • Date, Media, and Text Helpers
    • Creating Custom View Helpers
    • Localization
  • Database Interaction Through Models
    • Object Relational Mapping
    • Creating Records
    • Reading Records
    • Updating Records
    • Deleting Records
    • Column Statistics
    • Dynamic Finders
    • Getting Paginated Data
    • Associations
    • Nested Properties
    • Object Validation
    • Object Callbacks
    • Calculated Properties
    • Transactions
    • Dirty Records
    • Soft Delete
    • Automatic Time Stamps
    • Database Migrations
      • Migrations in Production
    • Using Multiple Data Sources
  • Plugins
    • Installing and Using Plugins
    • Developing Plugins
    • Publishing Plugins
  • Project Documentation
    • Overview
  • External Links
    • Source Code
    • Issue Tracker
    • Sponsor Us
    • Community
Powered by GitBook
LogoLogo
On this page
  • Synopsis
  • Description
  • Options
  • --env
  • --datasource
  • --remigrate
  • --verbose
  • --force
  • --dry-run
  • 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
  • Testing Migration Sequence
  • Fixing Migration Order Issues
  • Continuous Integration Setup
  • Important Warnings
  • Data Loss
  • Production Usage
  • Migration Dependencies
  • Best Practices
  • Process Flow
  • Notes
  • Related Commands

Was this helpful?

Edit on GitHub
Export as PDF
  1. Command Line Tools
  2. Command Reference
  3. Database Commands

wheels dbmigrate reset

Reset all database migrations by rolling back all executed migrations and optionally re-running them.

Synopsis

wheels dbmigrate reset [options]

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

  • Type: String

  • Default: development

  • Description: The environment to reset migrations in

--datasource

  • Type: String

  • Default: Application default

  • Description: Specify a custom datasource for the reset

--remigrate

  • Type: Boolean

  • Default: false

  • Description: After rolling back all migrations, run them all again

--verbose

  • Type: Boolean

  • Default: false

  • Description: Display detailed output during reset

--force

  • Type: Boolean

  • Default: false

  • Description: Skip confirmation prompts (use with caution)

--dry-run

  • Type: Boolean

  • Default: false

  • Description: Preview the reset without executing it

Examples

Reset all migrations (rollback only)

wheels dbmigrate reset

Reset and re-run all migrations

wheels dbmigrate reset --remigrate

Reset in testing environment with verbose output

wheels dbmigrate reset --env=testing --verbose

Force reset without confirmation

wheels dbmigrate reset --force --remigrate

Preview reset operation

wheels dbmigrate reset --dry-run --verbose

Use Cases

Fresh Development Database

Start with a clean slate during development:

# Reset and rebuild database schema
wheels dbmigrate reset --remigrate --verbose

# Seed with test data
wheels db seed

Testing Migration Sequence

Verify that all migrations run correctly from scratch:

# Reset all migrations
wheels dbmigrate reset

# Run migrations one by one to test
wheels dbmigrate up
wheels dbmigrate up
# ... continue as needed

Fixing Migration Order Issues

When migrations have dependency problems:

# Reset all migrations
wheels dbmigrate reset

# Manually fix migration files
# Re-run all migrations
wheels dbmigrate latest

Continuous Integration Setup

Reset database for each test run:

# CI script
wheels dbmigrate reset --env=testing --force --remigrate
wheels test run --env=testing

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:

  1. Take a complete database backup

  2. Put the application in maintenance mode

  3. Use the confirmation prompts (don't use --force)

  4. 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

  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. Use Confirmation: Don't use --force unless in automated environments

  5. Document Usage: If used in production, document when and why

Process Flow

  1. Confirms the operation (unless --force is used)

  2. Retrieves all executed migrations

  3. Rolls back each migration in reverse order

  4. Clears the migration tracking table

  5. 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

Previouswheels dbmigrate downNextwheels dbmigrate exec

Last updated 2 days ago

Was this helpful?

- Run the next migration

- Rollback last migration

- Run all pending migrations

- View migration status

- Seed the database with data

wheels dbmigrate up
wheels dbmigrate down
wheels dbmigrate latest
wheels dbmigrate info
wheels db seed