wheels dbmigrate remove table
Generate a migration file for dropping a database table.
Synopsis
Alias: wheels db remove table
Description
The dbmigrate remove table
command generates a migration file that drops an existing database table. The generated migration includes a dropTable() call in the up() method.
Parameters
name
string
Yes
The name of the table to remove
Examples
Basic table removal
Remove user table
Remove archive table
Generated Migration Example
For the command:
Generates:
Use Cases
Removing Temporary Tables
Clean up temporary or staging tables:
Refactoring Database Schema
Remove tables during schema refactoring:
Cleaning Up Failed Features
Remove tables from cancelled features:
Archive Table Cleanup
Remove old archive tables:
Safety Considerations
Data Loss Warning
CRITICAL: Dropping a table permanently deletes all data. Always:
Backup the table data before removal
Verify data has been migrated if needed
Test in development/staging first
Have a rollback plan
Dependent Objects
Consider objects that depend on the table:
Foreign key constraints
Views
Stored procedures
Triggers
Application code
Handling Dependencies
Be aware of dependent objects when removing tables:
Foreign key constraints
Views that reference the table
Stored procedures using the table
Application code dependencies
Best Practices
1. Document Removals
Add clear documentation about why the table is being removed:
2. Backup Data First
Before removing tables, create data backups:
3. Staged Removal
For production systems, consider staged removal:
4. Check Dependencies
Verify no active dependencies before removal:
Migration Structure
The generated migration contains:
An
up()
method withdropTable()
An empty
down()
method for you to implement rollback logic if needed
You should edit the down()
method to add table recreation logic if you want the migration to be reversible.
Recovery Strategies
If Removal Was Mistake
Don't run the migration in production
Use
wheels dbmigrate down
if already runRestore from backup if down() fails
Preserving Table Structure
Before removal, capture structure:
Notes
The command analyzes table structure before generating migration
Foreign key constraints must be removed before table removal
The migration is reversible if table structure is preserved
Always review generated migration before running
Related Commands
wheels dbmigrate create table
- Create tableswheels dbmigrate create blank
- Create custom migrationswheels dbmigrate up
- Run migrationswheels dbmigrate down
- Rollback migrationswheels db schema
- Export table schemas
Last updated
Was this helpful?