## TL;DR

For "Cannot apply --delete-class migration to class [ClassName] without also removing the binding that references it": remove the corresponding binding under [durable\_objects] in the Wrangler configuration file first, then apply --delete-class again.

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

## Steps

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

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

3. 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.

4. 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:

5. - 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.

6. - 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.

## When to use

Use this skill when you run into "Durable Objects: Cannot apply --delete-class migration (remove the binding first)".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
