Command Line Tools
Scaffold Cleanup
wheels destroy is the reverse of wheels generate. You hand it the same name you handed generate and it removes the files that were written. wheels d is a one-letter alias for the same command.
You’ll use this for:
- Undoing a scaffold you ran against the wrong name and want to redo.
- Removing an individual generated artifact — a model, a controller, a view directory — without touching the rest of the project.
- Cleaning up half-generated work when a
generaterun didn’t match what you meant to type.
Overview
Section titled “Overview”destroy mirrors a subset of the generate surface. For each supported type it removes the files the matching generator wrote, drops the corresponding .resources() line from config/routes.cfm when relevant, and stamps out a remove_<table>_table migration for types that own a schema. Files that weren’t generated — or that have already been removed — are reported as skipped, not errors.
wheels d is the same function under a shorter name. Every example on this page works with either destroy or d.
Synopsis
Section titled “Synopsis”wheels destroy <name> [type] [--force]wheels d <name> [type] [--force]The first positional argument is the resource name. The second, optional, is the type — resource (the default), model, controller, or view. --force must be passed for any deletion to actually occur; without it, destroy prints the preview and exits.
Running wheels destroy with no arguments prints the usage block and supported types.
Supported types
Section titled “Supported types”destroy handles four types. This is narrower than generate — there is no destroy scaffold, destroy migration, or destroy helper. Use resource (the default) for the full CRUD surface that generate scaffold writes.
| Type | What it removes |
|---|---|
resource (default) | Model CFC, controller CFC, views directory, model spec, controller spec, view-tests directory, .resources() route line, plus a new drop-table migration file |
model | Model CFC, model spec, plus a new drop-table migration file |
controller | Controller CFC and controller spec |
view | Entire view directory and its matching view-tests directory — or a single view file if you pass a controller/action path |
| Flag | Default | Description |
|---|---|---|
--force | off | Required to actually delete. Without --force, destroy prints the preview and exits. |
Example
Section titled “Example”wheels destroy Post# preview prints; nothing deleted yet
wheels destroy Post --forceThe second command removes app/models/Post.cfc, app/controllers/Posts.cfc, app/views/posts/, tests/specs/models/PostSpec.cfc, tests/specs/controllers/PostsControllerSpec.cfc, tests/specs/views/posts/, and the .resources("posts") line from config/routes.cfm. It also writes a new <timestamp>_remove_posts_table.cfc migration into app/migrator/migrations/ — you still need to run wheels migrate latest to actually drop the table from the database.
Safety notes
Section titled “Safety notes”Common workflows
Section titled “Common workflows”Undo a scaffold
Section titled “Undo a scaffold”wheels destroy Post --forcewheels migrate latest # apply the generated drop-table migrationRemoves every file wheels generate scaffold Post wrote, clears its route, and — after the migrate — drops the posts table.
Clean up aborted work
Section titled “Clean up aborted work”wheels destroy User model --forcewheels destroy Users controller --forceUseful when you ran wheels generate model and wheels generate controller separately, realised you named them wrong, and want to back out both without touching anything else. Each invocation is independent and prints its own preview when --force is omitted.
Re-scaffold under a new name
Section titled “Re-scaffold under a new name”wheels destroy Post --forcewheels migrate latestwheels generate scaffold Article title body:textwheels migrate latestTear down the old resource, apply the drop-table migration, and generate the new one. The two migrate runs keep the schema aligned with the filesystem at each step.