# Cannot apply --delete-class migration

When deleting a Durable Object class via `npx wrangler deploy --delete-class [ClassName]`, you may hit:

`Cannot apply --delete-class migration to class [ClassName] without also removing the binding that references it`

## The fix

Remove the corresponding binding under `[durable_objects]` in the Wrangler configuration file first, then apply `--delete-class` again. The binding keeps the class alive in the config; the migration refuses to delete a class that is still referenced.

## The broader lesson

Durable Object migrations (new classes, renamed classes, deleted classes) are declared in the Wrangler file's `migrations` array and applied on deploy. Common related failures:

- Forgetting the migration entry entirely: the deploy succeeds but the class change never takes effect on existing namespaces.
- Renaming a class without a `renamed_classes` migration: the new name is treated as a brand-new empty class; the old data sits orphaned under the old name.

## Checklist

- Delete class: remove binding first, then `--delete-class`.
- Rename class: use `renamed_classes`, verify data followed the name.
- New class: declare it in migrations before the first deploy that uses it.