new-migration
Skill44 starsChanged 4 months agoMITView on GitHub
Create a new database migration file with the correct next ID, preventing duplicates
- Deletes or force-pushes
6 other projects use a version of this.
Adopted by
Most recently taken up by
- violacase/Nuxt4-testtheir own version, first seen Oct 13, 2026
- fleetdm/fleettheir own version, first seen Oct 8, 2026
- CodeWithCJ/SparkyFitnesstheir own version, first seen Oct 8, 2026
- tstephx/book-mcp-servertheir own version, first seen Aug 19, 2026
- sebastiandev/ateliertheir own version, first seen Aug 19, 2026
- behradkhodayar/claude-code-py-ts-pgtheir own version, first seen Jul 1, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- fleetdm/fleet★ 7.2ksame name
- CodeWithCJ/SparkyFitness★ 6.8ksame name
- sebastiandev/atelier★ 8same name
- behradkhodayar/claude-code-py-ts-pg★ 1same name
- tstephx/book-mcp-server★ 1same name
- violacase/Nuxt4-test★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- new-migrationSkill
- scaffold-apiSkill
- scaffold-apiSkill
The file
We split this skill into the rules it gives an agent
9 rules. 0 are common, 3 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
Create a new database migration SQL file.
- Very specific: line 11
Read the current migration files in src/infrastructure/database/migrations/ and find the highest numbered migration file.
- Distinctive: line 23
All migrations 206+ MUST be safe and idempotent.
- Distinctive: line 52
NEVER create destructive migrations (DROP TABLE, DROP COLUMN)
- Very specific: line 53
Always use IF NOT EXISTS / IF EXISTS for idempotency
- Very specific: line 54
Always include user_id references where applicable (multi-tenant)
- Very specific: line 55
Use TIMESTAMPTZ for timestamps, not TIMESTAMP
- Very specific: line 56
Use gen_random_uuid() for UUID defaults
- Very specific: line 57
Use ON DELETE CASCADE for foreign keys to users(id)
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Create a new database migration SQL file. Follow these steps exactly:
Step 1: Find the next migration ID
Read the current migration files in src/infrastructure/database/migrations/ and find the highest numbered migration file. The new migration ID is that number + 1.
Known duplicate IDs: Migrations 116 and 133 have duplicates — be aware of this but it only matters if creating migrations in that range (you won't be).
Step 2: Create the migration file
Create: src/infrastructure/database/migrations/<ID>_$ARGUMENTS.sql
Example: If the highest migration is 226_add_user_quota.sql and the user wants "add_status_to_contacts", create 227_add_status_to_contacts.sql.
Step 3: Write safe, idempotent SQL
All migrations 206+ MUST be safe and idempotent. Use these patterns:
-- For new tables:
CREATE TABLE IF NOT EXISTS table_name (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- For new columns:
ALTER TABLE table_name ADD COLUMN IF NOT EXISTS column_name VARCHAR(100);
-- For indexes:
CREATE INDEX IF NOT EXISTS idx_table_column ON table_name(column_name);
-- For constraints:
DO $$ BEGIN
ALTER TABLE table_name ADD CONSTRAINT constraint_name UNIQUE (col1, col2);
EXCEPTION WHEN duplicate_object THEN NULL;
END $$;Step 4: Register in migrate.js
Open scripts/migrate.js and add the new migration filename to the SAFE_MIGRATIONS array at the end.
Rules
- NEVER create destructive migrations (DROP TABLE, DROP COLUMN)
- Always use
IF NOT EXISTS/IF EXISTSfor idempotency - Always include
user_idreferences where applicable (multi-tenant) - Use
TIMESTAMPTZfor timestamps, notTIMESTAMP - Use
gen_random_uuid()for UUID defaults - Use
ON DELETE CASCADEfor foreign keys tousers(id)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

