Declarative .mdcกฎ Cursor/Claude/Windsurf และเวิร์กโฟลว์ n8nกฎ IDEตรวจสอบการรั่วไหลแบบ Zero-Secret แล้ว

PostgreSQL 18 การโยกย้ายแบบปลอดภัยและกฎการจัดทำดัชนี JSONB GIN

ชุดกฎ Windsurf, Cursor และ Claude ที่ประกาศบังคับใช้ตัวป้องกัน lock_timeout การสร้างดัชนีพร้อมกัน และการเพิ่มประสิทธิภาพการบรรจุ jsonb_path_ops GIN

ไฟล์กฎตัวแทนและ 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'
```

หมายเหตุการตั้งค่าชุมชนและบทวิจารณ์การผลิต (0)

ยังไม่มีบันทึกของชุมชน แบ่งปันเคล็ดลับการกำหนดค่าการใช้งานจริงของคุณด้านล่าง

โพสต์บันทึกการตั้งค่าหรือเคล็ดลับการยืนยัน

เครื่องมือ MCP ที่เปิดเผยและตัวตรวจสอบสคีมาทรัพยากร

เครื่องมือ / ตัวระบุทรัพยากรพารามิเตอร์อินพุตพฤติกรรมการดำเนินการ
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.