CLI Overview
Quick Start Guide
wheels info
wheels reload
wheels deps
wheels destroy
wheels watch
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
wheels db create
wheels db drop
wheels db setup
wheels db reset
wheels db status
wheels db version
wheels db rollback
wheels db seed
wheels db dump
wheels db restore
wheels db shell
wheels db schema
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 test
wheels test run
wheels test coverage
wheels test debug
wheels config list
wheels config set
wheels config env
wheels env
wheels env setup
wheels env list
wheels env switch
wheels environment
wheels console
wheels runner
wheels server
wheels server start
wheels server stop
wheels server restart
wheels server status
wheels server log
wheels server open
wheels plugins
wheels plugins list
wheels plugins install
wheels plugins remove
wheels analyze
wheels analyze code
wheels analyze performance
wheels analyze security
wheels security
wheels security scan
wheels optimize
wheels optimize performance
wheels docs
wheels docs generate
wheels docs serve
wheels ci init
wheels docker init
wheels docker deploy
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
Configuration Management
Creating Commands
Service Architecture
Migrations Guide
Testing Guide
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
Using Multiple Data Sources
wheels destroy
Remove generated code and files associated with a model, controller, views, and tests.
Synopsis
wheels destroy <name>
wheels d <name>
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
| Argument | Description | Required |
|----------|-------------|----------|
| 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
/config/routes.cfm
- Database table (if confirmed)
Examples
Basic destroy
wheels destroy user
This will prompt:
================================================
= Watch Out! =
================================================
This will delete the associated database table 'users', and
the following files and directories:
/app/models/User.cfc
/app/controllers/Users.cfc
/app/views/users/
/tests/Testbox/specs/models/User.cfc
/tests/Testbox/specs/controllers/Users.cfc
/tests/Testbox/specs/views/users/
/config/routes.cfm
.resources("users")
Are you sure? [y/n]
Using the alias
wheels d product
Confirmation
The command always asks for confirmation and shows exactly what will be deleted:
================================================
= Watch Out! =
================================================
This will delete the associated database table 'users', and
the following files and directories:
/app/models/User.cfc
/app/controllers/Users.cfc
/app/views/users/
/tests/Testbox/specs/models/User.cfc
/tests/Testbox/specs/controllers/Users.cfc
/tests/Testbox/specs/views/users/
/config/routes.cfm
.resources("users")
Are you sure? [y/n]
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.cfm - Cleans up extra whitespace
- Removes
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
# Generated the wrong name
wheels generate resource prduct # Oops, typo!
wheels destroy prduct # Remove it
wheels generate resource product # Create correct one
Clean up after experimentation
# Try out a feature
wheels generate scaffold blog_post title:string content:text
# Decide you don't want it
wheels destroy blog_post
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