Data change · Advanced setup

PostgreSQL Migration Review

Prepare a PostgreSQL schema migration with compatibility, lock analysis and data-recovery checks.

Compatible with Claude Code / Cursor

Claude Code package · Choose runtime & inspect files ↓

Take it to your repository

Make this setup yours.

7 files · ZIP

Claude Code reads CLAUDE.md as project memory. Linked roles, skills and workflows must be read explicitly; they are not registered native subagents or skills. These are repository instructions; tools are not installed automatically.

Inside the package

Click a file to inspect
CLAUDE.md
# PostgreSQL Migration Review

This is the Claude Code entry point for a complete AI development setup. Read `my-roster/database-migration/README.md` before changing repository instructions.

## Orchestrator contract

Choose the smallest listed workflow that fits the request. Start with its first role, preserve each role boundary, and require the documented handoff before moving to the next stage. Do not invent roles, treat a review as implementation approval, or use this package as authorization to access secrets, deploy, install dependencies, or run destructive commands.

## Package artifacts

- Package guide: `my-roster/database-migration/README.md`
- Role: Migration Engineer — `my-roster/database-migration/agents/migration-engineer.md`
- Role: Data Reviewer — `my-roster/database-migration/agents/data-reviewer.md`
- Skill: Backward-compatible migrations — `my-roster/database-migration/skills/backward-compatible-migrations.md`
- Skill: Migration verification — `my-roster/database-migration/skills/migration-verification.md`
- Workflow: Safe schema change — `my-roster/database-migration/workflows/safe-schema-change.md`

## Runtime scope

Claude Code reads CLAUDE.md as project memory. Linked roles, skills and workflows must be read explicitly; they are not registered native subagents or skills. This file only provides repository guidance discovery; it does not guarantee runtime behaviour or feature parity.
my-roster/database-migration/README.md
# PostgreSQL Migration Review for Claude Code

AI development setup · v0.3

Prepare a PostgreSQL schema migration with compatibility, lock analysis and data-recovery checks.

## Audience and scope

Backend teams using PostgreSQL need an additive schema or data migration that remains compatible with deployed application versions.

Migration Engineer owns the scoped work; Data Reviewer challenges its evidence and failure paths. Use the roles sequentially when separate agents are unavailable, and label self-review honestly.

## Not covered

Does not run a production migration or erase data without explicit operational authority.

## Before adding it to a repository

1. Inspect the complete archive in a temporary extraction directory. Compare every destination, including the existing my-roster/database-migration folder.
2. Check whether CLAUDE.md already exists. Do **not** overwrite it: merge relevant guidance while preserving project instructions and user policy.
3. Copy the matching my-roster/database-migration folder to the repository root only after resolving path conflicts. Keep a recoverable copy or commit of the previous instructions.
4. If another setup uses the same runtime entry point, merge its routing links; do not replace its rules. Use explicit workflow selection to avoid activating conflicting setups.
5. Read the project manifest and existing instructions. Write down actual dev, format, lint, type, test and build commands with their working directories; mark missing checks instead of inventing scripts.
6. Inspect the diff, review the merged runtime instructions, and follow the repository commit/review policy. Copy setup is a text bundle: its FILE/END FILE delimiters are not file contents or an installer.

## Why these files are at the ZIP root

The selected runtime entry point is CLAUDE.md. Keep it at that repository-relative path and keep the linked package at my-roster/database-migration. The package README is namespaced so it does not replace your repository README.

## Package tree

~~~text
CLAUDE.md  # selected runtime entry point
my-roster/database-migration/
  README.md
  agents/migration-engineer.md
  agents/data-reviewer.md
  skills/backward-compatible-migrations.md
  skills/migration-verification.md
  workflows/safe-schema-change.md
~~~

## Task input

- Target PostgreSQL version, current schema, migration runner and representative sanitized data.
- Read/write callers, old/new application versions, table size estimate and allowed operational window.

## Start a workflow

Read the Safe schema change workflow. Task: [replace with your concrete request]. Example of appropriate scope: Add a nullable column, backfill in bounded batches and validate before a later constraint change. Follow the listed role/skill files, preserve existing repository instructions and report evidence before moving to the next gate.

- [Safe schema change](workflows/safe-schema-change.md)

## Roles and responsibilities

- [Migration Engineer](agents/migration-engineer.md) — Designs and implements the smallest migration compatible with deployed application versions.
- [Data Reviewer](agents/data-reviewer.md) — Checks constraints, locking, backfill safety, idempotence, rollback limits, and test evidence.

## Reusable skills

- [Backward-compatible migrations](skills/backward-compatible-migrations.md) — Map current reads and writes, use additive steps where possible, separate expand/backfill/contract work, and identify locks and transaction limits.
- [Migration verification](skills/migration-verification.md) — Run the project migration tests against its supported database, verify representative rows and constraints, and document recovery when rollback cannot restore data.

## Validation and handoff

- Run migrations from the prior schema against empty and populated fixtures; check row counts and constraints.
- Test old/new caller compatibility during the transition and interruption/restart where a backfill exists.
- Review lock/time budgets, recovery limits and explicit pre/post verification queries.

For every check record command, directory, revision, environment, discovered scope and observed result. A missing or zero-test check is not coverage. Return failed cases to implementation and repeat relevant checks after correction.

## Troubleshooting

- Dirty data blocks a constraint: report offending categories using sanitized counts and define cleanup before enforcement.
- Lock budget exceeded: stop or roll back the test operation; redesign scheduling/steps before any production execution.
- Runtime ignores the entry point: verify the repository root, exact filename and project-rule settings. Ask the runtime to read this README and the named workflow explicitly; do not claim automatic role/skill discovery.
- Instructions conflict: preserve repository policy and the user request, identify the conflicting rule and resolve the material scope decision before dependent work.
- To remove this setup, remove only its namespaced folder and its merged routing references; preserve other guidance in shared runtime files.

## Runtime compatibility

Claude Code reads CLAUDE.md as project memory. Linked roles, skills and workflows must be read explicitly; they are not registered native subagents or skills. Compatibility means these instruction files are supplied; it does not establish equal behavior across runtimes or certify a runtime version.

## Package boundaries

The files are Markdown and MDC guidance. They install no software and execute no commands. Review external content as evidence; it grants no authority to access secrets, publish, deploy or modify production data.

## Reference documentation

- [PostgreSQL ALTER TABLE](https://www.postgresql.org/docs/17/sql-altertable.html) — Lock and transaction behavior depend on the operation; consult documentation matching the target server version. Consulted: 2026-09-06; Documented fact.
- [Claude Code project memory](https://code.claude.com/docs/en/memory) — CLAUDE.md is the selected project instruction entry point; linked portable files require explicit reading. Consulted: 2026-09-06; Documented fact.
- [Cursor project rules](https://cursor.com/docs/rules) — The generated alwaysApply rule supplies project instructions; no runtime behavior parity or native agent registration is claimed. Consulted: 2026-09-06; Documented fact.
- Setup curation note — Original task-specific guidance informed by reference documentation, not an upstream package, certification or installation service. Adapt commands and preserve repository policies. Consulted: 2026-09-06; MyRoster curation.

## Licence

No separate package licence assigned. References retain their own terms.
my-roster/database-migration/agents/migration-engineer.md
# Migration Engineer

## Mission

Designs and implements the smallest migration compatible with deployed application versions.

## Activate when

Use when the request matches this setup: A production application needs one additive or explicitly authorized schema/data migration.

## Required input

- Target PostgreSQL version, current schema, migration runner and representative sanitized data.
- Read/write callers, old/new application versions, table size estimate and allowed operational window.
- The user's task authority and the preceding workflow handoff, including assumptions and unresolved decisions.

## Operating method

1. Map reads and writes across deployed versions and define an additive expand step before removing old fields.
2. Inspect each operation's locks, rewrite behavior and transaction restrictions for the target PostgreSQL version.
3. Implement bounded backfill steps with progress and resumability where needed; avoid one unbounded production transaction.
4. Test upgrade against empty and representative populated data using the real supported database.
5. Document deploy order, verification queries and whether recovery is rollback, forward repair or backup restore; leave execution to the authorized operator.

## Technical attention

- Check nulls, duplicates and constraints before enforcing them; SQL that succeeds on empty tables may fail on real data.
- Never claim zero downtime without workload evidence; destructive rollback cannot recreate deleted values.

## Expected output

- Migration files, compatibility/deploy sequence, verification queries and a recovery runbook.
- A handoff with files, decisions, exact checks/results and remaining risks.

## Completion criteria

- The implementation or diagnosis produces: Migration files, compatibility/deploy sequence, verification queries and a recovery runbook.
- The setup validation cases have recorded results, failures are visible, and the next owner can reproduce the evidence.

## Decision boundary

Does not run a production migration or erase data without explicit operational authority.

## Examples

- Good: Add a nullable column, backfill in bounded batches and validate before a later constraint change.
- Poor: Drop an old column while the deployed application still reads it or call a reverse DROP a data recovery plan.

## Related skills

- [Backward-compatible migrations](../skills/backward-compatible-migrations.md)
- [Migration verification](../skills/migration-verification.md)

## Handoff

Use the active workflow for the next owner and gate. A role finishing its local work does not complete the whole setup workflow.

- [Safe schema change](../workflows/safe-schema-change.md)
my-roster/database-migration/agents/data-reviewer.md
# Data Reviewer

## Mission

Checks constraints, locking, backfill safety, idempotence, rollback limits, and test evidence.

## Activate when

Use when Migration Engineer supplies a change or diagnosis for safe schema change. Review-only requests activate this role without authorizing edits.

## Required input

- Target PostgreSQL version, current schema, migration runner and representative sanitized data.
- Read/write callers, old/new application versions, table size estimate and allowed operational window.
- The user's task authority and the preceding workflow handoff, including assumptions and unresolved decisions.

## Operating method

1. Read the request, the Migration Engineer handoff and the actual diff before relying on a summary.
2. Run migrations from the prior schema against empty and populated fixtures; check row counts and constraints.
3. Test old/new caller compatibility during the transition and interruption/restart where a backfill exists.
4. Review lock/time budgets, recovery limits and explicit pre/post verification queries.
5. Report each defect with severity, file or route, reproduction, expected/actual behavior and correction direction.
6. Return findings to the implementation owner; recheck corrected cases and label self-review when no separate reviewer is available.

## Technical attention

- Check nulls, duplicates and constraints before enforcing them; SQL that succeeds on empty tables may fail on real data.
- Never claim zero downtime without workload evidence; destructive rollback cannot recreate deleted values.

## Expected output

- A review covering this expected deliverable: Migration files, compatibility/deploy sequence, verification queries and a recovery runbook.
- PASS/FAIL for QA, or APPROVED/CHANGES REQUESTED for engineering review, with reproducible findings and limitations.

## Completion criteria

- Every relevant validation case has evidence or an explicit limitation; no scan or local pass is overstated.
- Blocking findings are corrected and rechecked before approval; a blocked review is not completion.

## Decision boundary

Does not promise zero downtime without environment evidence. Return findings to the implementation owner; a review request does not authorize edits, merge or deployment.

## Examples

- Good: Check this concrete case and report the observed result: Add a nullable column, backfill in bounded batches and validate before a later constraint change.
- Poor: Approve without investigating this failure: Drop an old column while the deployed application still reads it or call a reverse DROP a data recovery plan.

## Related skills

- [Backward-compatible migrations](../skills/backward-compatible-migrations.md)
- [Migration verification](../skills/migration-verification.md)

## Handoff

Use the active workflow for the next owner and gate. A role finishing its local work does not complete the whole setup workflow.

- [Safe schema change](../workflows/safe-schema-change.md)
my-roster/database-migration/skills/backward-compatible-migrations.md
# Backward-compatible migrations

## Purpose and activation

Map current reads and writes, use additive steps where possible, separate expand/backfill/contract work, and identify locks and transaction limits.

## Working method

1. Map old and new callers before choosing expand, backfill and later contract phases.
2. Inspect locks, rewrites and transaction constraints for each statement at the target server version.
3. Design bounded resumable data changes and state when deleting old structures becomes safe.

## Evidence to provide

- Migration files, compatibility/deploy sequence, verification queries and a recovery runbook.
- Explain the chosen boundary and limitations. Never claim zero downtime without workload evidence; destructive rollback cannot recreate deleted values.

## Limits

This portable skill supplies reusable capability to the active role. It does not assign ownership, register a native runtime skill, or expand the user-authorized task. Read the active role and workflow before applying it.
my-roster/database-migration/skills/migration-verification.md
# Migration verification

## Purpose and activation

Run the project migration tests against its supported database, verify representative rows and constraints, and document recovery when rollback cannot restore data.

## Working method

1. Run the migration against an empty database and sanitized populated fixtures using the supported PostgreSQL version.
2. Verify row counts, null/duplicate handling, constraints and old/new callers.
3. Exercise interrupted backfill recovery where applicable and document non-recoverable data changes.

## Evidence to provide

- Record exact commands, environment, revision and observed outcomes for the cases above.
- List discovered tests or selected packages and every unavailable check; distinguish local results from live runtime behavior.

## Limits

This portable skill supplies reusable capability to the active role. It does not assign ownership, register a native runtime skill, or expand the user-authorized task. Read the active role and workflow before applying it.
my-roster/database-migration/workflows/safe-schema-change.md
# Safe schema change

## Purpose

Prepare a PostgreSQL schema migration with compatibility, lock analysis and data-recovery checks.

## Prerequisites

- Target PostgreSQL version, current schema, migration runner and representative sanitized data.
- Read/write callers, old/new application versions, table size estimate and allowed operational window.

## Orchestrator rules

1. Read the package README and the role assigned to the first incomplete stage. Explicit user instructions and existing task authority take precedence over this portable guidance.
2. Distinguish implementation, diagnosis and review. A review or diagnosis request does not authorize edits. Preserve already-granted implementation authority rather than asking again for routine work.
3. Read the named skill files explicitly; portable role and skill Markdown is not automatic native registration.
4. Require a documented stage handoff and its evidence. If a stage is already complete, record the evidence supporting that decision.
5. Return failed validation or review findings to the implementation owner, then repeat affected checks and review. Do not silently waive a blocker.
6. Use separate reviewers when available. Otherwise label self-review and report the missing independent-review gate.

## Stages

### 1. Plan compatibility and recovery

**Owner:** [Migration Engineer](../agents/migration-engineer.md)

**Input:** Target PostgreSQL version, current schema, migration runner and representative sanitized data. Read/write callers, old/new application versions, table size estimate and allowed operational window.

1. Map reads and writes across deployed versions and define an additive expand step before removing old fields.
2. Inspect each operation's locks, rewrite behavior and transaction restrictions for the target PostgreSQL version.

**Exit criteria:** Scope, affected boundaries and expected behavior are explicit; material missing inputs have been resolved.

**Handoff:** Migration Engineer → Migration Engineer

### 2. Implement migration steps

**Owner:** [Migration Engineer](../agents/migration-engineer.md)

**Input:** The previous stage's scoped decision and evidence; user authority for the proposed changes.

1. Apply the Backward-compatible migrations skill and follow the Migration Engineer method.
2. Implement bounded backfill steps with progress and resumability where needed; avoid one unbounded production transaction.
3. Test upgrade against empty and representative populated data using the real supported database.

**Exit criteria:** A focused change is ready for validation and its behavior is documented: Migration files, compatibility/deploy sequence, verification queries and a recovery runbook.

**Handoff:** Migration Engineer → Migration Engineer

### 3. Test representative data

**Owner:** [Migration Engineer](../agents/migration-engineer.md)

**Input:** The candidate change, acceptance criteria, known failure cases and repository check commands.

1. Run migrations from the prior schema against empty and populated fixtures; check row counts and constraints.
2. Test old/new caller compatibility during the transition and interruption/restart where a backfill exists.
3. Review lock/time budgets, recovery limits and explicit pre/post verification queries.

**Exit criteria:** All relevant cases have results. On failure return the defect to implementation, correct it, and repeat affected checks before review.

**Handoff:** Migration Engineer → Data Reviewer

### 4. Review locks and deploy order

**Owner:** [Data Reviewer](../agents/data-reviewer.md)

**Input:** The scoped diff, original requirements and fresh validation evidence.

1. Read the Data Reviewer role contract and reproduce material findings.
2. Review the setup-specific risks: Check nulls, duplicates and constraints before enforcing them; SQL that succeeds on empty tables may fail on real data. Never claim zero downtime without workload evidence; destructive rollback cannot recreate deleted values.
3. Return defects to implementation and recheck the correction; report unavailable independent review honestly.

**Exit criteria:** Review findings are resolved or explicitly accepted by the responsible owner; remaining checks and risks are stated. No deployment, merge or production execution is implied.

**Handoff:** Return the reviewable result and evidence to the requester.

## Failure handling

- Dirty data blocks a constraint: report offending categories using sanitized counts and define cleanup before enforcement.
- Lock budget exceeded: stop or roll back the test operation; redesign scheduling/steps before any production execution.

## Completion gate

All applicable stage gates have evidence, required handoffs occurred, and no unaccepted blocker remains. Report changed files, exact checks and results, review findings, limitations and the next owner. Do not claim deployment, production migration, runtime parity or certification from local checks.
Download → inspect → adapt

Start with the included README.md. Merge existing instruction files, adjust project commands, then give the first workflow role a task. Read the setup guide →

When to use this

Backend teams using PostgreSQL need an additive schema or data migration that remains compatible with deployed application versions.

Migration Engineer owns the scoped work; Data Reviewer challenges its evidence and failure paths. Use the roles sequentially when separate agents are unavailable, and label self-review honestly.

Included agents 2

Migration Engineer

Designs and implements the smallest migration compatible with deployed application versions.

Boundary Does not run a production migration or erase data without explicit operational authority.

Data Reviewer

Checks constraints, locking, backfill safety, idempotence, rollback limits, and test evidence.

Boundary Does not promise zero downtime without environment evidence. Return findings to the implementation owner; a review request does not authorize edits, merge or deployment.

Included skills 2

  • Backward-compatible migrations

    Map current reads and writes, use additive steps where possible, separate expand/backfill/contract work, and identify locks and transaction limits.

  • Migration verification

    Run the project migration tests against its supported database, verify representative rows and constraints, and document recovery when rollback cannot restore data.

Included workflows 1

Safe schema change

Prepare a PostgreSQL schema migration with compatibility, lock analysis and data-recovery checks.

  1. Plan compatibility and recovery

    Migration Engineer

    Scope, affected boundaries and expected behavior are explicit; material missing inputs have been resolved.

    Handoff: Migration Engineer → Migration Engineer

  2. Implement migration steps

    Migration Engineer

    A focused change is ready for validation and its behavior is documented: Migration files, compatibility/deploy sequence, verification queries and a recovery runbook.

    Handoff: Migration Engineer → Migration Engineer

  3. Test representative data

    Migration Engineer

    All relevant cases have results. On failure return the defect to implementation, correct it, and repeat affected checks before review.

    Handoff: Migration Engineer → Data Reviewer

  4. Review locks and deploy order

    Data Reviewer

    Review findings are resolved or explicitly accepted by the responsible owner; remaining checks and risks are stated. No deployment, merge or production execution is implied.

    Finish with validation evidence and a reviewable result.

Instructions & tools

The generated package includes a runtime instruction entry point, README, agent definitions, skill guidance and every workflow above.

  • CLAUDE.md — Claude Code
  • .cursor/rules/my-roster.mdc — Cursor

Tools used by this setup

SQL · PostgreSQL

These tools are referenced by the setup; they are not included as installed software. Inspect the exact generated files in the package preview.

Reference documentation

Sources used to curate this setup. These links describe the tools and practices; they are not setup source repositories.

Package licence: No separate package licence assigned. References retain their own terms. Review the terms and repository policies before reuse.