generate-migration

Generate Django Database Migrations

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "generate-migration" with this command: npx skills add getsentry/sentry/getsentry-sentry-generate-migration

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 sentry django sqlmigrate <app_name> <migration_name> to verify the SQL

Guidelines

Adding Columns

  • Use db_default=<value> instead of default=<value> for columns with defaults

  • Nullable columns: use null=True

  • Not null columns: must have db_default set

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 (null=True ) if not already

  • Remove all code references

  • Replace RemoveField with SafeRemoveField(..., deletion_action=DeletionAction.MOVE_TO_PENDING)

  • Deploy, then create second migration with SafeRemoveField(..., deletion_action=DeletionAction.DELETE)

Deleting Tables

  • Remove all code references

  • Replace DeleteModel with SafeDeleteModel(..., 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.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

design-system

No summary provided by upstream source.

Repository SourceNeeds Review
General

warden

No summary provided by upstream source.

Repository SourceNeeds Review
General

generate-frontend-forms

No summary provided by upstream source.

Repository SourceNeeds Review