Claude-skill-registry generate-migration
Generate Django database migrations for Sentry. Use when creating migrations, adding/removing columns or tables, adding indexes, or resolving migration conflicts.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/generate-migration" ~/.claude/skills/majiayu000-claude-skill-registry-generate-migration && rm -rf "$T"
manifest:
skills/data/generate-migration/SKILL.mdsource content
Generate Django Database Migrations
Commands
Generate migrations automatically based on model changes:
sentry django makemigrations
For a specific app:
sentry django makemigrations <app_name>
Generate an empty migration (for data migrations or custom work):
sentry django makemigrations <app_name> --empty
After Generating
- If you added a new model, ensure it's imported in the app's
__init__.py - Review the generated migration for correctness
- Run
to verify the SQLsentry django sqlmigrate <app_name> <migration_name>
Guidelines
Adding Columns
- Use
instead ofdb_default=<value>
for columns with defaultsdefault=<value> - Nullable columns: use
null=True - Not null columns: must have
setdb_default
Adding Indexes
For large tables, set
is_post_deployment = True on the migration as index creation may exceed the 5s timeout.
Deleting Columns
- Make column nullable (
) if not alreadynull=True - Remove all code references
- Replace
withRemoveFieldSafeRemoveField(..., deletion_action=DeletionAction.MOVE_TO_PENDING) - Deploy, then create second migration with
SafeRemoveField(..., deletion_action=DeletionAction.DELETE)
Deleting Tables
- Remove all code references
- Replace
withDeleteModelSafeDeleteModel(..., deletion_action=DeletionAction.MOVE_TO_PENDING) - Deploy, then create second migration with
SafeDeleteModel(..., deletion_action=DeletionAction.DELETE)
Renaming Columns/Tables
Don't rename in Postgres. Use
db_column or Meta.db_table to keep the old name.
Resolving Merge Conflicts
If
migrations_lockfile.txt conflicts:
bin/update-migration <migration_name>
This renames your migration, updates dependencies, and fixes the lockfile.