agentleFS
Baba01hacker666Baba01hacker666/dummyskills/skills/general-engineering/database-migration-helper/SKILL.md

database-migration-helper

Skill0 starsChanged 2 months agoMITView on GitHub

Guides agents through writing safe, zero-downtime, expand-and-contract database schema migrations without locking tables.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 7 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 14
  2. Very specific:

    Do not use for CSV file validation.

    line 20
  3. Very specific:

    If migration framework is unknown: inspect repository for prisma/, alembic/, migrations/.

    line 27
  4. Distinctive:

    Never author a migration that drops a column in the same release old code is running.

    line 28
  5. Distinctive:

    Follow these numbered actions:

    line 31
  6. Distinctive:

    Write non-blocking SQL/ORM migration script.

    line 37
  7. Distinctive:

    Write reversible rollback statement.

    line 39
  8. Very specific:

    Never set NOT NULL without a default on an existing populated table.

    line 45
  9. Distinctive:

    Stop and ask the user when:

    line 78
  10. Distinctive:

    CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_users_last_login_at ON users (last_login_at).

    line 102

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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 Migration Helper

Authors safe, backward-compatible database schema migrations. Enforces the "Expand and Contract" pattern, non-blocking column additions, and safe index creation.

1. Purpose

Prevent database outages and lockups during schema updates.

2. When to Use

Use this skill when:

  • Adding, renaming, or dropping database columns.
  • Adding indexes in production PostgreSQL/MySQL without locking writes.
  • Writing migration files (Prisma, TypeORM, Alembic, Django, Flyway, Goose).

3. When Not to Use

  • Do not use for CSV file validation; use csv-validator.

4. Required Inputs

  • table_name: Target database table.
  • schema_change: Proposed modification (e.g. "Add email_verified boolean column").

5. Missing-Input Behavior

  1. If migration framework is unknown: inspect repository for prisma/, alembic/, migrations/.
  2. Never author a migration that drops a column in the same release old code is running.

6. Procedure

Follow these numbered actions:

  1. Action 1: Identify Migration Pattern
    • Adding column: Must be nullable or have a default value.
    • Renaming column: Add new column, dual-write, backfill, drop old in subsequent release.
    • Adding index: Use CREATE INDEX CONCURRENTLY in Postgres.
  2. Action 2: Author Up Migration
    • Write non-blocking SQL/ORM migration script.
  3. Action 3: Author Down (Rollback) Migration
    • Write reversible rollback statement.
  4. Action 4: Emit Migration Plan
    • Format per Section 8.

7. Decision Rules

  • In PostgreSQL: never run CREATE INDEX without CONCURRENTLY on high-traffic tables.
  • Never set NOT NULL without a default on an existing populated table.

8. Output Format

Emit the report using this template:

### Database Migration Plan: [Table Name]

- **Framework**: [Prisma | Alembic | Raw SQL | Goose]
- **Migration Name**: `[e.g. 20260910_add_verified_to_users]`
- **Lock Risk**: [LOW (Zero-downtime) | HIGH (Table lock)]

#### Migration UP
```sql
[Safe SQL Migration]

Migration DOWN (Rollback)

[Rollback SQL]

## 9. Verification Checklist
- [ ] New column is nullable or has default value.
- [ ] Indexes created concurrently.
- [ ] Rollback statement verified.

## 10. Common Failures and Recovery
| Failure Symptom | Cause | Recovery Action |
| :--- | :--- | :--- |
| Table locked for 30 minutes | `CREATE INDEX` without `CONCURRENTLY` | Add `CONCURRENTLY` keyword and run outside transaction. |

## 11. Stop or Escalation Conditions
Stop and ask the user when:
- Migration requires table-rewriting locks on tables with millions of rows.

## 12. Examples

### Example 1: Successful Execution
**Input:**
```text
Table: users
Change: Add last_login_at timestamp
DB: PostgreSQL

Output:

### Database Migration Plan: users

- **Framework**: PostgreSQL SQL
- **Migration Name**: `20260910_add_last_login_at_to_users`
- **Lock Risk**: LOW (Zero-downtime)

#### Migration UP
```sql
ALTER TABLE users ADD COLUMN last_login_at TIMESTAMPTZ NULL;
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_users_last_login_at ON users (last_login_at);

Migration DOWN (Rollback)

DROP INDEX CONCURRENTLY IF EXISTS idx_users_last_login_at;
ALTER TABLE users DROP COLUMN IF EXISTS last_login_at;

### Example 2: Ambiguous or Missing Input
**Input:**
```text
Change database.

Output:

### Database Migration Plan: Halted - Missing Details

- **Status**: Halted

Please provide the target table name and proposed column changes.

Example 3: Expected Final Output

Output:

### Database Migration Plan: orders

- **Framework**: PostgreSQL SQL
- **Migration Name**: `20260910_add_status_index`
- **Lock Risk**: LOW

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.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.