deckhearth/.cursor/rules/schema-map.mdc

31 lines
1.3 KiB
Text
Raw Normal View History

bootstrap: agent pipeline v0.5.0 + ship-readiness review Installs the three-layer agent-pipeline scaffold (https://github.com/varutasu/agent-pipeline @ v0.5.0): L1 — Context (curated brain) - AGENTS.md: orientation, conventions, 8 explicit gotchas - .cursor/rules/: no-go-zones, api-routes, auth-and-permissions, db-and-schema, ui-and-theming, schema-map - .cursor/skills/: add-api-route, add-page recipes - docs/agent-context/README.md: layer explainer - docs/SCHEMA_MAP.md: hand-curated Neon Postgres reference (replaces Prisma schema map since stack is raw SQL) L2 — Subagent roles (copied verbatim from upstream templates) - 9 .cursor/agents/role-*.md files: Conductor, IA-Architect, UX-Reviewer, Architect, Implementer, Reviewer, Design-System-Auditor, A11y-Auditor, Doc-Writer L3 — Pipeline scaffolding (Vercel variant) - CI: lint + schema-map-drift only (no duplicate build — Vercel handles it). Test job commented out until vitest lands. - preview-smoke + visual-diff via wait-for-vercel-preview - pr-health-rollup sticky comment aggregator - agent-context-drift weekly cron - PULL_REQUEST_TEMPLATE, CODEOWNERS (auth/admin paths tagged) - .convoys/ folder + seed ship-readiness.md review - lib/flags/index.js (JS — converted from TS template) - scripts/wt.sh (Cursor 3.2 deprecation stub), scripts/log-convoy-event.sh - tests/smoke/app.smoke.spec.ts (Playwright skeleton) Manifest - .agent-context-manifest.yml: tracks 31 artifacts by sha256 for future sync-agent-context drift detection Review - .convoys/ship-readiness.md: 16 findings (7 P0 ship-blockers, 5 P1 quality-bar, 4 P2 refactor, P3 UX/IA/a11y/docs) with proposed 13-convoy launch sequence. No production code changed in this commit. All findings in the ship-readiness review will be addressed in follow-up convoys starting with fix-auth-bypass. Structural brain: user-code-review-graph MCP has indexed the codebase (122 files, 628 nodes, 5602 edges, 11 communities, 84 flows). Per-developer; not committed. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 00:16:08 -04:00
---
description: Schema map — when an agent needs to know what columns exist on which table
globs: pages/api/**/*.js,scripts/**/*.js,lib/database.js,lib/permission-middleware.js
---
# Use the schema map
Before writing any SQL that touches a column you haven't verified:
1. **Read [`docs/SCHEMA_MAP.md`](../../docs/SCHEMA_MAP.md)** — it's the curated reference.
2. If the column isn't documented there, search the migration scripts:
```
rg "<column_name>" scripts/
```
3. If still no match, **stop and ask** — don't guess column names; Postgres won't be polite.
## When to update the schema map
After running any `scripts/add-*.js` / `scripts/fix-*.js` or any direct `ALTER TABLE`, update the matching table section in `docs/SCHEMA_MAP.md` in the same PR. The CI gate `schema-map-fresh` will fail if a `scripts/add-*.js` is added without a corresponding update.
## Common reference
- **Auth check inside an API route** → `users` (id, email, role)
- **Card lookup** → `cards` (id, name, scryfall_id UNIQUE, game)
- **What a user owns** → `user_cards` (user_id, card_id, quantity, is_foil)
- **Collection card list** → `collection_cards` JOIN `cards`
- **Permission check** → `collection_permissions` (collection_id, user_id, role, status='active')
- **Activity feed** → `collection_activity` (action, details JSONB)