Skip to content
cccskills
FreePublished on GitHub

database-setup

PostgreSQL setup: migrations, indexing, schema design, expand-contract, ER diagrams. golang-migrate/Prisma/drizzle.

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

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

Run score Not tested

See how to install

Files included (2)

  • SKILL.md3.9 KB
  • references/indexing-guide.md3.9 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

database-setup — Migrations, Indexing & Schema

Cuándo usar

Setup DB local (Docker+migrations), crear/correr/rollback migrations, diseñar/auditar índices, generar diagrama ER, cambios schema en producción.

1. Migrations

Herramienta

StackToolNotas
Gogolang-migrate/migrateCLI + librería, SQL puro
TS + Prismaprisma migrateIntegrado con ORM
TS + Drizzledrizzle-kitSQL-like, type-safe
TS sin ORMnode-pg-migrateSQL puro

No mezclar herramientas en mismo repo.

Naming

YYYYMMDDHHMMSS_description.up.sql + .down.sql. Timestamp UTC, snake_case, verbo al inicio. Nunca editar migration ya mergeada.

Zero-downtime: expand-contract

FaseQuéRelease
ExpandColumna NULLABLE/DEFAULT, tabla nueva, índice CONCURRENTLYN
BackfillJob async, idempotente, batcheado ~10k, checkpointN
Dual-writeApp escribe viejo Y nuevoN+1
Migrate readsLecturas apuntan a nuevoN+2
ContractDROP viejo tras validar (≥1 release estable)N+3

DDL y data SIEMPRE separados. Mezclar causa locks largos y rollbacks imposibles.

Locks

SET lock_timeout = '5s'; SET statement_timeout = '30s'; antes de ALTER. ADD COLUMN con DEFAULT no-volátil instantáneo desde PG 11. NOT NULL existente: ADD CHECK NOT VALID → VALIDATE en migration separada.

Rollback

CambioRollback
DDL aditivo (ADD/CREATE)Reversible con DROP
DDL destructivo (DROP, ALTER TYPE lossy)One-way, documentar
Data transformation lossyOne-way

Siempre .down.sql aunque sea vacío documentado. CI: up → down → up.

2. Indexing

Tipos: B-tree (95% — equality/range/sort), GIN (arrays/jsonb/tsvector), GiST (geo/ranges), BRIN (huge ordered tables).

Reglas clave: Composite order = igualdad → rango → ORDER BY. FK child siempre indexado (PG no lo hace automático). CREATE INDEX CONCURRENTLY obligatorio en prod. Si el índice queda INVALID → DROP y recrear.

Para guía completa (tipos, variantes partial/covering/expression, CONCURRENTLY, JSONB, queries de detección), leer references/indexing-guide.md.

3. Multi-tenant

tenant_id como primera columna en todo composite. RLS como defense in depth. Backfills considerar todos tenant_id. Schema-per-tenant: iterar lista, trackear progreso parcial.

4. ER Diagram

Escanear migrations SQL / ORM models → generar Mermaid erDiagram. >20 tablas: agrupar por dominio. Marcar nullable, PK, FK. Relaciones: ||--o{ (1:N), ||--|| (1:1), }o--o{ (N:M).

Anti-patterns

  • DDL + data en mismo archivo
  • DROP COLUMN sin período gracia
  • CREATE INDEX sin CONCURRENTLY en prod
  • Editar migration mergeada
  • ADD COLUMN NOT NULL con DEFAULT volátil
  • Composite orden incorrecto
  • Indexar baja cardinalidad sola (boolean)
  • No indexar FK child
  • Nunca REINDEX

Checklist

Setup

  • Docker Compose o script setup local documentado
  • .env.example con DATABASE_URL

Migrations

  • Naming YYYYMMDDHHMMSS, un cambio lógico por migration
  • DDL y data separados
  • .down.sql existe o documenta one-way
  • lock_timeout + statement_timeout en ALTER
  • CI: up → down → up
  • Breaking: plan expand-contract documentado

Indexing

  • Query concreta, EXPLAIN muestra Seq Scan
  • Tipo índice correcto
  • Composite: igualdad → rango → ORDER BY
  • CONCURRENTLY fuera de transacción
  • FKs con índice en child
  • Post-creación: EXPLAIN ANALYZE confirma plan

ER

  • Diagrama actualizado tras cambio schema

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