Declarative .mdcReglas Cursor/Claude/Windsurf y flujos de trabajo n8nRegla IDEFuga de secreto cero auditada

PostgreSQL 18 migraciones Lock-Safe y reglas de indexación JSONB GIN

Conjunto de reglas declarativas de Windsurf, Cursor y Claude que aplican protecciones lock_timeout, creación CONCURRENTE de índices y optimización de contención de GIN jsonb_path_ops.

Agente declarativo y archivos de reglas IDE

---
description: Lock-safe PostgreSQL 18 DDL migrations, JSONB GIN indexing, and query latency guardrails
globs: **/*.{sql,prisma,go}
alwaysApply: false
---

# PostgreSQL 18 Zero-Downtime DDL & Indexing Rules

- Prefix every production migration with `SET lock_timeout = '2s'; SET statement_timeout = '30s';` so blocked DDL aborts cleanly instead of queueing reads.
- Build new indexes on populated tables using `CREATE INDEX CONCURRENTLY IF NOT EXISTS` outside explicit transaction blocks.
- Use `USING GIN (column jsonb_path_ops)` for JSONB containment (`@>`) workloads to reduce index footprint by up to 60%.
- Add `NOT NULL` constraints on existing large tables via `CHECK (...) NOT VALID` followed by `VALIDATE CONSTRAINT` before setting `NOT NULL`.
- Verify every new list/filter query with `EXPLAIN (ANALYZE, BUFFERS)` to prevent sequential scans on tables exceeding 10,000 rows.

## Verification Check
```bash
grep -rn 'CREATE INDEX ' migrations/ | grep -v 'CONCURRENTLY' && exit 1 || echo 'All indexes concurrent-safe'
```

Notas de configuración de la comunidad y reseñas de producción (0)

Aún no hay notas comunitarias. Comparta su consejo de configuración de producción a continuación.

Publicar una nota de configuración o un consejo de verificación

Inspector de esquema de recursos y herramientas MCP expuesto

Identificador de herramienta/recursoParámetros de entradaComportamiento de ejecución
lock_safe_ddl_guardmigrations/**/*.sqlRequires lock_timeout = '2s' and CREATE INDEX CONCURRENTLY on live tables.
jsonb_gin_operator_classschema.sqlSelects jsonb_path_ops GIN indexes for fast @> containment lookups.