agentleFS
EstebanT1112EstebanT1112/codex-engineering-workflow/skills/database-migrations/SKILL.md

database-migrations

Skill0 starsChanged 2 months agoMITView on GitHub

Plan, implement, review, and verify database schema or data migrations with engine-aware locking, compatibility, backfill, rollback, and deployment sequencing. Use for migration files and persistent schema/data changes; do not use for ordinary application queries without a migration.

52 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use deployment-patterns, postgres-patterns and 6 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • royaluniondesign-sysSkill

    deployment-patterns

    Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications.

    Also in 6 projects that use this

  • nek1987Skill

    postgres-patterns

    PostgreSQL patterns for reviewing migrations and writing efficient queries. Use when reviewing Alembic migrations, optimizing queries, or debugging database issues.

    Also in 7 projects that use this

  • nek1987Skill

    redis-patterns

    Upstash Redis patterns for caching and rate limiting.

    Also in 3 projects that use this

  • seikaikyoSkill

    fastapi-patterns

    FastAPI + SQLModel + Neon PostgreSQL 後端開發最佳實踐。適用於 Render 部署的 API 服務。涵蓋路由設計、資料庫操作、錯誤處理、認證授權。

    Also in 3 projects that use this

  • MicrosoftSkill

    python-testing

    Write and run Python tests for the VoxelPic library. USE FOR: adding new pytest test cases, understanding the Python API and test patterns, debugging Python test failures, or running the existing Python test suite.

    Also in 5 projects that use this

  • junimnjwSkill

    agent-harness-construction

    Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 12 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 48 edited versions we read keep these.

  • 12

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat a migration as a versioned compatibility change across database state, application versions, data volume, and deployment order.

    line 11
  2. Distinctive:

    Use a single migration only when the change is demonstrably compatible and bounded.

    line 30
  3. Distinctive:

    Expand: add compatible schema without removing the old contract.

    line 32
  4. Distinctive:

    Contract: remove obsolete schema only after usage and rollback windows permit it.

    line 35
  5. Distinctive:

    Never edit a migration known to be applied in a shared environment unless the project explicitly uses a safe reconciliation procedure.

    line 51
  6. Distinctive:

    Follow the repository's naming and ordering.

    line 55
  7. Distinctive:

    Keep the migration focused and deterministic.

    line 56
  8. Distinctive:

    Avoid hidden network calls, production credentials, or environment-dependent data.

    line 57
  9. Distinctive:

    Add guards only when supported and consistent with migration history.

    line 58
  10. Distinctive:

    Update application code in the sequence required for compatibility.

    line 59
  11. Distinctive:

    Document an irreversible step and its recovery path.

    line 60
  12. Distinctive:

    Staging/production: only with explicit authorization and operational controls.

    line 69

“Common” is measured: kept by at least 6 in 10 of the 48 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Database Migrations

Treat a migration as a versioned compatibility change across database state, application versions, data volume, and deployment order.

Discover before designing

Identify:

  • database engine and version;
  • ORM or migration tool and its pinned version;
  • repository migration conventions and applied-history rules;
  • table size, write pattern, constraints, indexes, triggers, and dependent code when known;
  • whether the target is a local/disposable database, staging, or production;
  • rollout and rollback capabilities.

Consult current engine/tool documentation when lock, DDL, transaction, or online-index behavior matters. Do not generalize PostgreSQL syntax or guarantees to other databases.

For PostgreSQL, also use the selected PostgreSQL skill for SQL, RLS, indexing, concurrency, and constraint details.

Choose a safe lifecycle

Use a single migration only when the change is demonstrably compatible and bounded. Use expand/contract when old and new application versions may overlap:

  1. Expand: add compatible schema without removing the old contract.
  2. Migrate: backfill in bounded, restartable batches where volume requires it; validate progress and consistency.
  3. Switch: deploy code that reads the new representation and stops depending on the old one.
  4. Contract: remove obsolete schema only after usage and rollback windows permit it.

Separate schema and data operations when doing so reduces locks, transaction duration, rollback risk, or operational ambiguity. It is a decision based on the actual engine and tool, not an absolute formatting rule.

Safety questions

  • What application versions can run before, during, and after the migration?
  • Can the operation lock or rewrite a large table?
  • Is a default computed per row or metadata-only in this engine/version?
  • Can index or constraint validation be staged?
  • Is the backfill idempotent, observable, bounded, and resumable?
  • What happens to concurrent writes?
  • How is partial failure detected and resumed?
  • Is rollback safe, or is roll-forward the correct recovery strategy?
  • Are destructive steps delayed until data is no longer needed?

Never edit a migration known to be applied in a shared environment unless the project explicitly uses a safe reconciliation procedure.

Implementation

  • Follow the repository's naming and ordering.
  • Keep the migration focused and deterministic.
  • Avoid hidden network calls, production credentials, or environment-dependent data.
  • Add guards only when supported and consistent with migration history.
  • Update application code in the sequence required for compatibility.
  • Document an irreversible step and its recovery path.

Verification levels

Report exactly which level was achieved:

  1. Static: syntax, formatting, schema diff, generated SQL, or migration graph inspected.
  2. Disposable database: apply from the correct prior state, inspect schema/data, run affected tests, and exercise rollback or roll-forward where meaningful.
  3. Representative-volume test: evaluate locks, duration, batching, and disk/replication impact with representative data.
  4. Staging/production: only with explicit authorization and operational controls.

Static validation alone does not prove a migration applies successfully. A local empty database does not prove production-scale safety.

Approval boundaries

Preparing migration files and testing in an authorized disposable database are ordinary implementation work. Applying a destructive/breaking migration, changing production data, or using production credentials requires explicit approval immediately before the operation.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.