Skip to content
cccskills
FreePublished on GitHub

data-migrations

DB migrations Postgres: DDL/DML, expand-contract zero-downtime, rollbacks, locks, CONCURRENTLY, batching, multi-tenant.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3 stars(GitHub 3 + cccskills 0)
Works withPostgreSQL

Run score Not tested

See how to install

Files included (5)

  • SKILL.md5.1 KB
  • references/anti-patterns.md549 B
  • references/batching.md373 B
  • references/checklist.md610 B
  • references/expand-contract.md947 B

SKILL.md (original)

Review the instructions the agent will receive before you install.

Data Migrations — Educabot

Route

Intención del usuarioModoQué hace
"nueva migration", "agregar columna", "crear tabla", "rename"CREATEGenera archivos .up.sql + .down.sql con naming correcto
"correr migrations", "aplicar", "migrate up", "deploy migration"RUNValida staging → ejecuta → confirma estado
"revertir", "rollback", "deshacer migration", "migrate down"ROLLBACKVerifica .down.sql, evalúa riesgo, ejecuta con backup previo
"qué migrations hay", "estado", "pendientes", "aplicadas"STATUSmigrate version + lista pendientes vs aplicadas

Regla: si la intención combina CREATE + RUN, hacer en ese orden. Si es ROLLBACK destructivo, pedir confirmación explícita.


Migraciones de DB sin romper producción. Stack: Postgres con golang-migrate (Go) o Prisma Migrate (TS).

Cuándo usar / NO usar

UsarNO usar
Schema: CREATE/ALTER TABLE, ADD COLUMN, índicesSeeds de datos de prueba (usar fixtures)
Data: backfills, transformaciones, normalizacionesLookup tables triviales de dev local
Rename/drop columnas o tablas en prodScripts one-shot limpieza manual (usar job)
ALTER TYPE, split/merge tablas, multi-tenantCambios de config app (env/config)

Herramientas

StackToolArchivos
Go (default)golang-migrate/migratemigrations/NNNNNNNNNNNNNN_nombre.up.sql + .down.sql
TS (Prisma)Prisma MigrateSi usa Prisma como ORM
TS (pg directo)node-pg-migrateSi usa pg sin ORM
TS (Drizzle)drizzle-kitSi stack Drizzle

Alinear herramienta con ORM elegido. No mezclar dos sistemas en mismo repo.

Naming

Formato: YYYYMMDDHHMMSS_description.up.sql + .down.sql. Timestamp UTC (no secuenciales). Description snake_case con verbo (add_, create_, drop_, alter_, backfill_). Una migration = un cambio lógico atómico. Nunca editar migration ya mergeada a main.

Zero-downtime: expand-contract

Todo breaking change se divide en múltiples releases (expand → backfill → dual-write → migrate reads → contract).

→ Read references/expand-contract.md for fases detalladas y breaking changes multi-step

Índices

  • Siempre CREATE INDEX CONCURRENTLY en tablas con datos (no bloquea writes)
  • No puede correr dentro de transacción — usar -- +migrate NoTransaction (golang-migrate) o --create-only + editar SQL (Prisma)
  • Si falla: queda INVALID → DROP INDEX → reintentar

Locks y timeouts

ALTER TABLE toma ACCESS EXCLUSIVE LOCK. Patrón seguro: SET lock_timeout = '5s'; SET statement_timeout = '30s'; antes del ALTER. Si no consigue lock → falla rápido → retry con backoff. ADD COLUMN con DEFAULT no-volátil es instantáneo desde PG 11. ADD COLUMN NOT NULL DEFAULT <volátil> reescribe tabla — evitar.

Batching (data migrations grandes)

Keyset pagination (id > last_id), batch 10k, checkpoints, idempotente, job separado.

→ Read references/batching.md for reglas completas de batching

Rollback

  • DDL aditivo (ADD/CREATE) → reversible con DROP
  • DDL destructivo (DROP) → one-way, datos perdidos
  • Data migration lossy → one-way
  • Siempre escribir .down.sql (aunque sea NO-OP documentado)
  • One-way críticos: backup previo obligatorio

Staging y CI

  • Staging = subset anonimizado de prod. Correr toda migration antes que prod. Medir tiempo.
  • CI (obligatorio en PR): up desde limpio → down → up otra vez (valida reversibilidad + idempotencia). Lint SQL si configurado.

Multi-tenant

PatrónCómoCuándo
Shared schema (default Educabot)Una migration global, backfills consideran todos tenant_idSaaS standard
Schema-per-tenantRunner itera tenants, trackea fallo parcialAislamiento medio
Database-per-tenantMáximo aislamientoSolo enterprise compliance

Anti-patterns

→ Read references/anti-patterns.md for lista completa (12 items)

Delegación

  • /db-diagram — ER diagram post-migration
  • /deploy-check — checklist deploy con migration
  • /audit-dev — revisión integral migrations acumuladas
  • /scaffold-go — setup golang-migrate en proyecto nuevo

Checklist

→ Read references/checklist.md for checklist completo (12 items)

  • Expand-contract pattern used for all breaking schema changes
  • Both .up.sql and .down.sql files exist for every migration
  • lock_timeout and statement_timeout configured before ALTER statements
  • Migration tested and timed in staging with production-like data
  • Rollback verified by running .down.sql then .up.sql again
  • Indexes created with CONCURRENTLY outside transactions on populated tables

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Plan, design, and implement A/B tests and experiments with statistical rigor. Covers hypothesis frameworks, sample sizing, metrics, and result analysis.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

Web/mobile accessibility decision guide: WCAG 2.2 AA, ARIA, keyboard nav, focus management, contrast, testing. Use for: a11y, accessibility, wcag, aria, screen reader, keyboard, contrast.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

Generate, iterate, and scale ad creative for paid advertising across Google, Meta, LinkedIn, and X. Covers platform specs, creative frameworks, and quality validation.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

Musica interactiva para juegos: layering vertical, re-secuenciacion horizontal, stingers, reglas de transicion con sync points, y mapeo de estados de gameplay a musica. Usar para: musica adaptativa, sistema de musica dinamica, transiciones musicales, combat music.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

Design multi-agent systems, create agent architectures, define communication patterns, and build autonomous agent workflows with structured evaluation frameworks.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

Inter-agent communication protocol for C-suite agent teams. Defines invocation syntax, loop prevention, isolation rules, response formats, and quality loops.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

See all skills by SebastianLuser

Report a problem with this skill