schema-migration-safety
Plan and apply backwards-compatible two-step schema changes for Django migrations without using jig.
- License 许可
- MIT
- 最近更新
- 2026-04-10
- Stars
- ★ 6
- Forks
- 0
01 前言 Front Matter
- name
- schema-migration-safety
- description
- Plan and apply backwards-compatible two-step schema changes for Django migrations without using jig.
03 SKILL.md 正文
Schema Migration Safety (Control)
Use this skill for model field changes that need rollout-safe migrations. Implement the file edits directly. Do not return a checklist-only response.
Required Variables
app_labelmodel_namefield_namefield_typeadd_field_kwargsfinal_field_kwargsprevious_migrationadd_migration_namefinalize_migration_namebackfill_value
Required Output Contract
- Update
models.pysoclass Entity(models.Model)containsclassification = models.CharField(max_length=20)as the final model field shape. - Create the first migration file using the provided
add_migration_name. - In the first migration:
- import
migrationsandmodels - define
backfill_classification(apps, schema_editor) - use
model_cls = apps.get_model(app_label, model_name)with the provided variable values - use
db_alias = schema_editor.connection.alias - iterate
for row in model_cls.objects.using(db_alias).all().only("id", field_name):with the provided field name literal - when the field is
Noneor"", set it to the provided backfill value and callrow.save(update_fields=["{{ field_name }}"]) - declare
migrations.AddField(...)with the safe first-state kwargs from the variables - declare
migrations.RunPython(backfill_classification, migrations.RunPython.noop)
- Create the second migration file using the provided
finalize_migration_name. - In the second migration:
- depend on the first migration by its provided
add_migration_name - declare
migrations.AlterField(...)with the final field kwargs from the variables
- Keep the migration chain linear and use the exact migration filenames provided in the variables.
Guardrails
- Avoid one-shot
NOT NULLadditions on large existing tables. - Avoid data backfill in request-time code paths.
- Keep backfill logic idempotent.
- Do not write a custom reverse-backfill function; use
migrations.RunPython.noop.
04 同仓库更多 Skills
velocity
Systematic DX improvement hunt — find friction, inconsistency, and missing abstractions across PRs, code, or tickets, then feed findings into /improve. Use when looking for ways to accelerate development or compound Claude Code's utility.
upgrade
Upgrade an existing skill or agent by auditing it, gathering user references, and rewriting it with real content. Use when a skill is thin, sloppy, missing gotchas, or needs improvement. Different from /improve which creates new extensions.
improve
Deliberately improve Claude Code by creating or updating skills, agents, hooks, rules, or MCP servers. Use when Claude keeps making the same mistake, a workflow is tedious, a new pattern needs enforcement, or you want to compound Claude's utility.
clean-copy
Recreate the current branch with a clean, narrative commit history. Use before creating a PR from a messy development branch, after exploratory coding with WIP commits, or when commit history is hard to review.
audit
Audit installed skills and agents against best practices. Use when reviewing skill quality, checking for common problems, or before upgrading existing skills. Read-only — produces a report, changes nothing.
typescript-update-model
暂无简介