sql-migrations

sql-migrations is a cursor rule for Cursor from golid-ai/golid. It costs 0 tokens per session (1,000 once invoked), scanned A, original, MIT.

A set of rules for SQL migration files, which record database structure changes such as tables, columns, indexes, triggers, and data types.

In plain words
What is it for?
Use it when creating or changing database schemas, naming migration files, adding indexes or columns, and writing matching forward and rollback changes.
Why use it?
It prevents different environments from ending up with different database structures by keeping schema changes in an append-only history.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/. Also seen: positional $N argument.

Good fit Use it when creating or changing database schemas, naming migration files, adding indexes or columns, and writing matching forward and rollback changes.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/golid-ai/golid/sql-migrations
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/golid-ai/golid

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for sql-migrations

README.md
[![agentmods](https://agentmods.dev/badge/rules/golid-ai/golid/sql-migrations/github.svg)](https://agentmods.dev/rules/golid-ai/golid/sql-migrations)
Your own site
<a href="https://agentmods.dev/rules/golid-ai/golid/sql-migrations"><img src="https://agentmods.dev/badge/rules/golid-ai/golid/sql-migrations/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for sql-migrations

Your own site · 80×15
<a href="https://agentmods.dev/rules/golid-ai/golid/sql-migrations"><img src="https://agentmods.dev/badge/rules/golid-ai/golid/sql-migrations.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,000 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01000
Opus 5.5 $0.00000 $0.00400
Sonnet 5.5 $0.00000 $0.00200
Haiku 4.5 $0.00000 $0.00100

Measured 3mo ago against content hash 7496b38d03c5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

sql-migrations scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/sql-migrations.mdc · 116 lines

How it starts

The opening of the file, as written. The whole thing — 116 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SQL Migration Patterns

Thesis: Migrations are the source of truth for the data model. Every table gets UUIDs, TIMESTAMPTZ, FK indexes, and an updated_at trigger.

Reference files: 000001_init.up.sql

File Naming

000NNN_description.up.sql and 000NNN_description.down.sql — always create both.

Once Committed, Never Edited

Migrations are append-only history. Once a migration file is committed, even on a feature branch, do not modify it. Any schema change goes in a new migration with the next sequence number.

  • Need to add a column? New ALTER TABLE ... ADD COLUMN.
  • Need to drop a column you just added? New ALTER TABLE ... DROP COLUMN.
  • Forgot an index? New CREATE INDEX.

Editing an already-committed .up.sql silently desyncs schemas: any environment that ran the old version will never pick up the change, while fresh databases will. Before editing any 00NN_*.sql file, ask: "is this committed?" If yes, create a new migration.

Up Migration

-- Enums first
CREATE TYPE item_status AS ENUM ('new', 'in_progress', 'complete', 'cancelled');

-- Tables (with UUID PKs, timestamps, FKs with ON DELETE CASCADE)
CREATE TABLE items (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  title TEXT NOT NULL,
  status item_status DEFAULT 'new',
  created_at TIMESTAMPTZ DEFAULT NOW(),
  updated_at TIMESTAMPTZ DEFAULT NOW()
);

-- Indexes on FKs and frequently filtered columns
CREATE INDEX idx_items_user_id ON items(user_id);
CREATE INDEX idx_items_status ON items(status);

-- Reuse the existing updated_at trigger function
CREATE TRIGGER items_updated_at BEFORE
UPDATE ON items FOR EACH ROW EXECUTE FUNCTION update_updated_at();

Down Migration

Drop in reverse dependency order: columns (ALTER), then tables, then enums.

DROP TABLE IF EXISTS item_history;
DROP TABLE IF EXISTS items;
DROP TYPE IF EXISTS item_status;

Conventions

  • UUIDs for all primary keys (not serial/bigint).
  • TIMESTAMPTZ for all timestamps (not TIMESTAMP).
  • TEXT for strings (not VARCHAR) — PostgreSQL treats them identically.
  • DECIMAL(x,2) for money/hours (not FLOAT).
  • JSONB for structured metadata (audit trails, preferences).
  • TEXT[] for tag-like arrays (skills, industries).
  • Enums for finite status sets — add a cancelled state if the entity can be deactivated.
  • ON DELETE CASCADE on child table FKs.
  • Index every FK and every column used in WHERE filters.
  • updated_at trigger on every table that has the column.

Read the full file on GitHub · 116 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 116 lines · 0 tokens per session scan A 7496b38d03c5

Subscribe to this mod's changes

sql-migrations is a cursor rule published in the GitHub repository golid-ai/golid (41 stars, last pushed 5mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,000 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

sql-migrations compared with cursor rules from other repositories

sql-migrations next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
sql-migrationsgolid-ai/golidCursor rule415mo agoMITA0Cursor
git-commitsprest/prestCursor rule4.6k3d agoMITA963Cursor
adapter-unit-testsprest/prestCursor rule4.6k3d agoMITA0Cursor
token-optimizationprest/prestCursor rule4.6k3d agoMITA876Cursor
planning-and-delegationprest/prestCursor rule4.6k3d agoMITA912Cursor
integration-testsprest/prestCursor rule4.6k3d agoMITA0Cursor
config-resilienceprest/prestCursor rule4.6k3d agoMITA0Cursor