wheels destroy
Remove generated code and files associated with a model, controller, views, and tests.
Synopsis
Description
The wheels destroy
command removes all files and code associated with a resource that was previously generated. It's useful for cleaning up mistakes or removing features completely. This command will also drop the associated database table and remove resource routes.
Arguments
name
Name of the resource to destroy
Yes
Options
This command has no additional options. It always prompts for confirmation before proceeding.
What Gets Removed
When you destroy a resource, the following items are deleted:
Model file (
/app/models/[Name].cfc
)Controller file (
/app/controllers/[Names].cfc
)Views directory (
/app/views/[names]/
)Model test file (
/tests/Testbox/specs/models/[Name].cfc
)Controller test file (
/tests/Testbox/specs/controllers/[Names].cfc
)View test directory (
/tests/Testbox/specs/views/[names]/
)Resource route entry in
/app/config/routes.cfm
Database table (if confirmed)
Examples
Basic destroy
This will prompt:
Using the alias
Confirmation
The command always asks for confirmation and shows exactly what will be deleted:
Safety Features
Confirmation Required: Always asks for confirmation before proceeding
Shows All Changes: Lists all files and directories that will be deleted
Database Migration: Creates and runs a migration to drop the table
Route Cleanup: Automatically removes resource routes from routes.cfm
What Gets Destroyed
Files Deleted:
Model file
Controller file
Views directory and all view files
Test files (model, controller, and view tests)
Database Changes:
Creates a migration to drop the table
Runs
wheels dbmigrate latest
to execute the migration
Route Changes:
Removes
.resources("name")
from routes.cfmCleans up extra whitespace
Best Practices
Commit First: Always commit your changes before destroying
Review Carefully: Read the confirmation list carefully
Check Dependencies: Make sure other code doesn't depend on what you're destroying
Backup Database: Have a database backup before running in production
Common Workflows
Undo a generated resource
Clean up after experimentation
Notes
Cannot be undone - files are permanently deleted
Database table is dropped via migration
Resource routes are automatically removed from routes.cfm
Only works with resources that follow Wheels naming conventions
See Also
wheels generate resource - Generate resources
wheels generate scaffold - Generate scaffolding
wheels dbmigrate remove table - Remove database tables
Last updated
Was this helpful?