Agent skill

Saleor Django Migration Rules

by saleor in saleor/saleor

Rules for writing Django migrations in Saleor that avoid long table locks and stay compatible with zero-downtime rolling deploys.

BSD-3-ClauseAuto-check passedDatabases

Install Saleor Django Migration Rules

skills CLI
$ npx skills add saleor/saleor --skill saleor-migrations -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install saleor/saleor saleor-migrations --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/saleor/saleor.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/saleor-migrations .claude/skills/saleor-migrations && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
saleor-migrations
GitHub stars
23k
Token cost
~1.6k tokens
SKILL.md length
835 words
Files
1
Skills in repo
8
Repo updated
First seen
Licence
BSD-3-Clause

At a glance

Rules for writing Django migrations in Saleor that avoid long table locks and stay compatible with zero-downtime rolling deploys.

  • Works in 3 steps: N — add a db_default (or null=True) so… → N+1 — de-register the field from the… → N+2 — drop the column, now that no…
  • Creating or editing a Django schema or data migration in Saleor
  • SKILL.md covers Keep locks short: split…, Indexes and constraints:…, Backwards compatibility: the… and Data migrations, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Saleor deploys across many pods against one shared Postgres, so a migration that holds a long table lock stalls every pod. The skill keeps locks short by requiring one model and one field change per migration, separating schema from data migrations, avoiding a second alteration of a column an earlier migration already changed, and naming migrations after the actual operation. Unique constraints and indexes are added concurrently, since a plain AddConstraint or AddIndex takes a blocking lock, and invariants such as non-negative balances go into database check constraints.

Backward compatibility is the default: during a rolling deploy, pods on the previous version talk to the already migrated database. New fields must be nullable or carry a db_default, because Django's plain default never reaches the database. Removing a field is staged across three releases, starting with a db_default and then removing the field from the ORM state while the column stays, using SeparateDatabaseAndState.

When your agent uses it

  • Creating or editing a Django schema or data migration in Saleor
  • Removing a field without breaking a rolling deploy
  • Adding a unique constraint or index on a busy table
  • Reviewing a migration for lock risk

Example prompts

  • “Write a migration that adds a brand column to the payment model without locking the table.”
  • “Plan the removal of the legacy slug field across releases.”
  • “Review this migration for blocking locks and rolling-deploy safety.”

Requirements

  • A Saleor checkout with Django and PostgreSQL

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. N — add a db_default (or null=True) so the DB can write the column without the ORM.
  2. N+1 — de-register the field from the ORM, leaving the column in place, via
  3. N+2 — drop the column, now that no process uses it. Track it as an explicit follow-up.

What it can do on your machine

Read from SKILL.md and the folder at commit 782a751. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Saleor Django Migration Rules loads about 1.6k tokens when it runs. Until then it costs about 60 tokens; SKILL.md has 835 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~60
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from saleor/saleor at commit 782a751, republished under its BSD-3-Clause licence (© saleor). 835 words, ~1,602 tokens.

Download SKILL.mdSave it as .claude/skills/saleor-migrations/SKILL.md (or your agent's skills folder).
name
saleor-migrations
description
Rules for writing safe Django migrations in Saleor that don't lock tables or break zero-downtime deploys. Use whenever creating or editing a migration (schema or data), including field removals and index/constraint changes.

Writing Saleor migrations

Saleor deploys with zero downtime across many pods against a shared Postgres. A migration that takes a long table lock stalls every pod. Follow these rules.

Keep locks short: split migrations

  • One model per migration, and one field change per migration. Each schema operation holds a lock on the table for its duration; batching several into one migration multiplies the locked time.
  • The only valid reason to combine is separating a schema migration from its data migration.
  • Always separate schema changes and data migration.
  • Don't add a migration that re-alters a column an earlier migration already changed — check the existing migration history first.
  • Give migrations descriptive names that reflect the actual operation (0070_add_payment_gift_card_brand, not 0070_alter_payment_partial_add_db_default for something else).

Indexes and constraints: create concurrently

  • Add unique constraints/indexes concurrently using the established non-blocking pattern (see e.g. page migration 0030_slug_translation_unique_constraint) — a plain AddConstraint / AddIndex takes a blocking ACCESS EXCLUSIVE lock and can stall writes across all pods.
  • Enforce value invariants (e.g. non-negative balance) with a DB CheckConstraint, not just application logic.

Backwards compatibility: the new schema must work with the old code

During a rolling deploy, pods running the previous minor version talk to the already-migrated database. Django SELECTs and UPDATEs every column it knows about, so the schema must stay valid for that old ORM. Making the DB backwards-compatible is the default; changing old code requires crafting two releases at once — reserve it for cases where nothing else works.

Adding a field

Old pods insert rows without knowing the column, so it must be writable without them: null=True or a db_default. Plain Django default= is not enough — it lives in Python and never reaches the database.

Removing a field: stage it across three releases

Removing a NOT NULL / defaulted column in one step can fail mid-deploy while old and new pods coexist.

  1. N — add a db_default (or null=True) so the DB can write the column without the ORM.
  2. N+1 — de-register the field from the ORM, leaving the column in place, via SeparateDatabaseAndState: state_operations=[RemoveField(...)] and database_operations that make the column nullable. Old pods still find the column; new pods no longer touch it.
  3. N+2 — drop the column, now that no process uses it. Track it as an explicit follow-up.
python
migrations.SeparateDatabaseAndState(
    database_operations=[
        migrations.AlterField(
            model_name="sitesettings",
            name="automatically_confirm_all_new_orders",
            field=models.BooleanField(null=True, blank=True),
        ),
    ],
    state_operations=[
        migrations.RemoveField(
            model_name="sitesettings",
            name="automatically_confirm_all_new_orders",
        ),
    ],
)

Keep any legacy enum values / code retained only for migration safety tracked as a removal task with a "remove in X.Y" note.

Renaming or moving a field

Avoid unless necessary — a rename is an add plus a remove, so it costs the same three releases.

  1. N — add the new field (null=True), and write both old and new fields everywhere the old one is written, so old pods keep seeing valid data. Add a data migration that backfills the new field. Note in the upgrade guide that N+1 requires upgrading to this patch release first.
  2. N+1 — read from the new field. Re-run the backfill data migration (old pods may have inserted rows in the old format between step 1's migration and the cutover), then drop null=True from the new field. De-register the old field per "Removing a field" step 2.
  3. N+2 — drop the old column.

Handle "new field is null but old one isn't" while both exist.

Any data migration that reshapes data written by old pods runs twice — once before the new code deploys, once in the next version when the old code is provably gone.

Show full SKILL.md (274 more words)Show less

Data migrations

  • A data migration must be all-or-nothing: process everything or nothing. Don't abort partway on a fixed depth/count cap and leave a partial migration.
  • post_migrate sender must be the migration's own app config — a common copy-paste bug is registry.get_app_config("product") inside an account/order migration.
  • Use a module/task constant (like BATCH_SIZE) for internal tuning knobs, not an env var nobody will set.
  • When cleaning up (e.g. removing a permission), address all models that hold the value (App, AppExtension, AppInstallation, …), or document why one is handled elsewhere.
  • Watch for per-iteration DB queries (O(N) vs O(1)); batch related lookups.

Cross-branch ports

  • Keep a ported migration's filename identical to its counterpart on the other branch, and add a merge migration where histories diverge.
  • Keep a ported migration's filename identical to its counterpart on the other branch, and add a merge migration where histories diverge using ./manage.py makemigrations --merge.

Before requesting review

  • Confirm each migration touches a single model and a single field, and that any index or constraint is created concurrently rather than with a blocking operation.
  • Confirm every destructive column change is staged across releases (add db_default, then remove the field from the ORM via SeparateDatabaseAndState, then drop the column in a later version).
  • Confirm every new column is nullable or has a db_default — a Python-only default= leaves old pods unable to insert.
  • Confirm any data migration over data old pods still write is scheduled to run again in the next version.
  • Confirm each post_migrate handler passes its own app config as the sender, and that every data migration is all-or-nothing rather than aborting partway.
  • Run the migration locally with manage.py migrate and confirm it applies cleanly.

© saleor, BSD-3-Clause. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/saleor-migrations of saleor/saleor.

Open the folder on GitHubat commit 782a751

Compare with similar skills

Saleor Django Migration Rules next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Saleor Django Migration Rules compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Saleor Django Migration Rules this skillsaleor/saleor23k—~1.6kAutomated safety check: PassBSD-3-Clause
Safe Database Migration Patternsaffaan-m/ECC276k—~3.3kAutomated safety check: PassMIT
Profiling Slow API EndpointsPostHog/posthog40k—~1kAutomated safety check: PassCustom licence
Supabase Postgres Best Practicessupabase/agent-skills2.7k24 repos~808Automated safety check: PassMIT
Database Migrationagulli/atlas-agents579—~702Automated safety check: PassMIT
DB ContextSilvioBaratto/optimizer176—~6.4kAutomated safety check: NotesCustom licence

Similar skills

  • Rules and examples for safe, reversible schema changes in production: zero-downtime column and index changes, large data backfills and ORM migration workflows.

    276k GitHub stars~3.3k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Official

    Profiles slow PostHog API endpoints when the main cost is in Postgres or Python.

    40k GitHub stars~1k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Official

    Gives the agent Postgres rules to consult before writing or changing tables, queries, indexes, RLS policies or migrations, and when diagnosing slow queries.

    2.7k GitHub starsUsed in 24 repos~808 tokens
    DatabasesAuto-check passed
  • Database Migration

    agulli/atlas-agents

    Safely run database schema migrations. An agent skill from agulli/atlas-agents.

    579 GitHub stars~702 tokensUpdated 2 mo ago
    DatabasesAuto-check passed
  • DB Context

    SilvioBaratto/optimizer

    Complete knowledge of the optimizer PostgreSQL database: 57 ingestion tables, schema, relationships, live row counts, query patterns, and conventions.

    176 GitHub stars~6.4k tokensUpdated 4 days ago
    DatabasesAuto-check: notes
  • DB Migration

    hiromaily/go-crypto-wallet

    Database schema and migration workflow. An agent skill from hiromaily/go-crypto-wallet.

    128 GitHub stars~652 tokensUpdated 5 mo ago
    DatabasesAuto-check passed

More from saleor/saleor

All 8 skills in this repo
  • Benchmarks Django ORM filters in Saleor by generating bulk data, extracting the SQL and running EXPLAIN ANALYZE to check index usage.

    23k GitHub stars~2.3k tokensUpdated yesterday
    Auto-check passed
  • Commits changes in the Saleor codebase and works through pre-commit hook failures from ruff, mypy, the GraphQL schema check and the migrations check.

    23k GitHub stars~575 tokensUpdated yesterday
    Auto-check passed
  • Generates and splits Django schema migrations for Saleor with manage.py makemigrations, enforcing one new model or one field change per migration file.

    23k GitHub stars~1k tokensUpdated yesterday
    Auto-check passed
  • Pytest Runner

    saleor/saleor

    Run pytest tests with automatic virtual environment activation. Use this skill whenever running tests, executing pytest, or when asked to "run tests", "test…

    23k GitHub stars~251 tokensUpdated yesterday
    Auto-check passed
  • Saleor Port Changes

    saleor/saleor

    Forward-ports or backports a single PR or branch onto the currently checked-out Saleor branch, handling GraphQL version markers and migration numbering along the way.

    23k GitHub stars~969 tokensUpdated yesterday
    Auto-check passed
  • Checklist for adding, changing, deprecating or removing Saleor GraphQL fields, mutations, enums and webhook event types so the change passes review first time.

    23k GitHub stars~1.2k tokensUpdated yesterday
    Auto-check passed

Questions about Saleor Django Migration Rules

What does Saleor Django Migration Rules do?

Rules for writing Django migrations in Saleor that avoid long table locks and stay compatible with zero-downtime rolling deploys. Saleor deploys across many pods against one shared Postgres, so a migration that holds a long table lock stalls every pod. The skill keeps locks short by requiring one model and one field change per migration, separating schema from data migrations, avoiding a second alteration of a column an earlier migration already changed, and naming migrations after the actual operation.

When should I use Saleor Django Migration Rules?

Saleor Django Migration Rules fits situations like: creating or editing a Django schema or data migration in Saleor; removing a field without breaking a rolling deploy; adding a unique constraint or index on a busy table; reviewing a migration for lock risk.

How do I install Saleor Django Migration Rules in Claude Code?

Run `npx skills add saleor/saleor --skill saleor-migrations -a claude-code`. Or copy the skill folder (.claude/skills/saleor-migrations in saleor/saleor) into .claude/skills/saleor-migrations in your project. Claude Code loads it when a task matches its description.

How do I install Saleor Django Migration Rules in Codex?

Run `npx skills add saleor/saleor --skill saleor-migrations -a codex`. Or copy the skill folder (.claude/skills/saleor-migrations in saleor/saleor) into .agents/skills/saleor-migrations in your project. Codex loads it when a task matches its description.

Can I use Saleor Django Migration Rules in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add saleor/saleor --skill saleor-migrations -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/saleor-migrations, .gemini/skills/saleor-migrations, .github/skills/saleor-migrations and .opencode/skills/saleor-migrations in your project.

What does Saleor Django Migration Rules need to run?

SKILL.md names no scripts, command-line tools or credentials: Saleor Django Migration Rules is instructions for the agent only. Our summary lists: A Saleor checkout with Django and PostgreSQL.

Does Saleor Django Migration Rules access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Saleor Django Migration Rules safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Saleor Django Migration Rules use?

Saleor Django Migration Rules is published under the BSD-3-Clause licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Saleor Django Migration Rules use?

About 1.6k tokens (SKILL.md is roughly 6.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Saleor Django Migration Rules?

Skills that share tags, products or a category with Saleor Django Migration Rules: Safe Database Migration Patterns (affaan-m/ECC, 276k stars), Profiling Slow API Endpoints (PostHog/posthog, 40k stars), Supabase Postgres Best Practices (supabase/agent-skills, 2.7k stars) and Database Migration (agulli/atlas-agents, 579 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Saleor Django Migration Rules?

saleor (a GitHub organization) maintains it in saleor/saleor, which has 23,428 GitHub stars. The repository holds 8 skills in this directory. The repository was last updated on October 9, 2026.

Source: saleor/saleor on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.