Relational Schema
FreeAdd tables with keys, constraints, and indexes that match the queries you will actually run.
Purpose
Prevent stringly JSON blobs and unindexed filters for new features.
Procedure
--- name: relational-schema description: Add tables with keys, constraints, and indexes that match the queries you will actually run. ---
Relational Schema
Purpose
Prevent stringly JSON blobs and unindexed filters for new features.
Procedure
Read the existing migrations before adding a table. Extend, do not fork.
For a new table:
- A primary key.
- Foreign keys for references you intend to keep in sync, with an explicit delete behavior (cascade, restrict, or set null). Do not leave orphans by accident.
- Not-null for fields the UI always needs. Use a default only when it is true (status defaults to draft, not to published).
- A unique constraint for the real-world identity (one save per user per skill, one slug).
- Indexes for the filters and sorts the API exposes. Do not index every column.
- Timestamps if the product shows "updated" or you audit changes.
User ids in this stack are text, not uuid.
Write a new migration file. Do not edit a migration that has already been applied.
Avoid storing secrets, card numbers, or access tokens in the new table. Store a provider reference.
If you are tempted to add a JSON column for a structured thing you will query, use columns instead.
Example requests
1. Add reviews
Request: You already have a reviews table. Explain, using Relational Schema, which constraints matter and do not add a duplicate table. Expected: A description of primary key, uniqueness per user, and the index you would need for a new query.
Dependencies
None. Work in the repository that is already open. Do not add packages unless the procedure names one.
Compatibility
This document follows the Agent Skills layout (a folder named relational-schema containing SKILL.md). Claude Code, Cursor, Codex, and Gemini CLI can load that file from the paths in the Skilling installation guide. GitHub Copilot does not load SKILL.md. Use the Copilot instructions copy, and narrow applyTo before you commit it. Last verified 2026-11-15.
Example prompts
Add reviews
You already have a reviews table. Explain, using Relational Schema, which constraints matter and do not add a duplicate table.
Expected: A description of primary key, uniqueness per user, and the index you would need for a new query.
Install for GitHub Copilot
- 1Copy Relational Schema with “Copy for Copilot”. That file is the instruction Copilot reads.
- 2In this repository, save it at .github/instructions/relational-schema.instructions.md.
- 3The applyTo line should match the files this procedure is for. Use a narrow path when you know it.
- 4Repository-wide notes stay in .github/copilot-instructions.md and should stay short. This procedure does not go there.
- 5Open Copilot in this repository and ask it to follow Relational Schema.
Related
- Query Scoping
Scope every read and write of personal rows by the session user, in the query itself.
- Migration Plan
Plan a schema or data change as expand, migrate, then contract, without editing applied migrations.
- Schema Contracts
Validate input at the server boundary and return a stable error shape.
Reviews
No reviews yet.
Sign in to review.
Report a problem
Inaccurate steps, an unsafe instruction, or a licensing concern.
Sign in to report.