← ClaudeAtlas

database-zero-downtime-migratorlisted

Generates Expand-and-Contract (Parallel Change) migration SQL as four ordered stage files plus a JSON manifest from a MigrationPlan, emitting Postgres or MySQL dialect output through a Python stdlib argparse module.
RMAzrim/opencode-artes · ★ 2 · Data & Documents · score 76
Install: claude install-skill RMAzrim/opencode-artes
# Database Zero-Downtime Migrator ## 1. System Architecture & Prerequisites The skill generates a **four-stage Expand-and-Contract (Parallel Change)** migration for relational schemas so that application code and schema stay compatible at every step. It is a *SQL emitter* — it never connects to a database. The agent runs the generated files in order. Stage pipeline: 1. **Expand** — add new (nullable) columns; nothing breaks, reads still work. 2. **Dual-Write** — a DB trigger (or the app layer) keeps new columns in sync with legacy columns on every insert/update. 3. **Backfill** — batch `UPDATE` loops fill historical rows, 1000 rows/chunk. 4. **Contract** — once verification reports zero mismatches and all reads use the new columns, drop the legacy columns (reversible only via re-expand). Prerequisites: - **Python 3.9+** with the standard library only (`argparse`, `dataclasses`, `enum`, `json`, `pathlib`, `datetime`). No external packages. - **Target database client** to execute emitted SQL: - **PostgreSQL 11+** — generated code uses `CREATE OR REPLACE FUNCTION`, `EXECUTE FUNCTION`, `ADD COLUMN IF NOT EXISTS`, `DROP COLUMN IF EXISTS`, and `DO $$ ... $$` blocks. - **MySQL 8.0.19+** — generated code uses `ADD COLUMN IF NOT EXISTS`, `DROP COLUMN IF EXISTS`, derived-table subqueries for batched `UPDATE`, and `DELIMITER` client directives (must be run through the `mysql` client, not an API driver). - No ORM, no migration framework, no network p