db-migration
Skill3 starsChanged 35 days agoMITView on GitHub
Create and apply a Drizzle schema change. Use when adding or altering tables, columns, or indexes in @packages/db, or when asked for a migration.
- Reads credentials
24 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- ricci-labs/twisetheir own version, first seen Nov 8, 2026
- aniketshukla1/sdlc-kittheir own version, first seen Nov 8, 2026
- globalmpc/backendskillstheir own version, first seen Nov 8, 2026
- F3-Nation/f3-nationtheir own version, first seen Nov 2, 2026
- andidev30/the-artifacttheir own version, first seen Oct 20, 2026
- lepresk/groundworktheir own version, first seen Oct 15, 2026
Used with
Projects with it also use write-tests, git-workflow and 3 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SentrySkillwrite-tests
Write tests following project conventions. Use when adding new tests or modifying existing ones.
Also in 3 projects that use this
Microsoft AzureSkillgit-workflow
Squad branching model: dev-first workflow with insiders preview channel
Also in 3 projects that use this
Microsoft AzureSkillverify
End-to-end app testing pipeline for browser-based web apps on cloud browsers via Azure Playwright Workspaces: verify the live app, author tests for working flows, heal failing tests, then re-run with video and produce one consolidated report. Three phases (app verification, test authoring, test healing) plus a scoped final sanity run; each phase emits a sub-report. Use when asked to "verify my app", "make sure my app works and has good test coverage", "do a full QA pass", "add tests where I'm missing coverage", "fix failing tests and add new ones", "smoke test before deploy", "QA my deployment", or any combined verify-and-test ask. Requires Azure CLI (`az login`) and a Playwright Workspace resource ID — bootstraps configs on first invocation. Browser-based web apps with Playwright only — not for unit/API tests, native mobile/desktop, load/perf, or full accessibility audits.
Also in 4 projects that use this
AnthropicSkilldebug
Structured debugging session — reproduce, isolate, diagnose, and fix. Trigger with an error message or stack trace, "this works in staging but not prod", "something broke after the deploy", or when behavior diverges from expected and the cause isn't obvious.
Also in 3 projects that use this
GoogleSkillgrill-me
A relentless interview to sharpen a plan or design.
Also in 3 projects that use this
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- nrjdalal/zerostarter★ 6599% same
Wrote their own version · 23
- dipu-bd/lightnovel-crawler★ 2.6ksame name
- lncrawl/lightnovel-crawler★ 2.6ksame name
- openmeterio/openmeter★ 2.4ksame name
- F3-Nation/f3-nation★ 210same name
- hiromaily/go-crypto-wallet★ 128same name
- xin-lai/CodeSpirit★ 56same name
- globalmpc/backendskills★ 44same name
- NicholasFlemmer/styx-app★ 31same name
- nikandr-surkov/ai-saas-starter★ 16same name
- viknesh20-20/claude-code-tool-kit★ 7same name
13 more not listed
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 repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- add-packageSkill
- agent-browserSkill
- api-endpointSkill
- auditSkill
- codebase-mapSkill
- designSkill
- devSkill
- docker-testSkill
- doc-syncSkill
- fontsSkill
- gh-commitSkill
- iceboxSkill
- ignore-syncSkill
- portlessSkill
- releaseSkill
- runtime-apisSkill
- shadcn-syncSkill
- shipSkill
- skills-managerSkill
- ui-verifySkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 21 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 33
Read the generated packages/db/drizzle/NNNN_*.sql.
- Distinctive: line 73
Never edit an applied migration.
“Common” is measured: kept by at least 6 in 10 of the 21 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
[!CAUTION] Synced from https://github.com/nrjdalal/zerostarter. Customize this skill or remove this note to stop syncing.
Database Migration
PostgreSQL with Drizzle ORM. Schema lives in packages/db/src/schema/, migrations in packages/db/drizzle/. Schema, SQL, and snapshot travel together in one PR.
0. Show the schema and wait
Never generate or apply a migration before the user has seen the schema and said go. Post the table or the altered columns, name the choices that are hard to reverse (nullability, what a null means, foreign keys and their delete behaviour, indexes, whether anything is derived or generated, retention), and stop there.
Two reasons this is a hard stop rather than a courtesy. A shape is cheap to argue about and expensive to change once rows exist, so the review has to happen before the write. And canary and production share one database, so applying reaches production the moment it runs, not when the release ships.
1. Edit the schema
auth.tsis generated, never edited: declare a plugin or anadditionalFieldscolumn inpackages/auth/src/schema.ts, runbun run auth:schema, then continue below with the regenerated file. A hand edit failstests/packages/db/src/schema/auth.test.ts.- Schema files group by concern, not one per table:
auth.tsholds the Better Auth tables,console.tsthe ones the console owns. A new table joins the file for its concern, or starts a new one when it is a new concern, and that file needs an export fromindex.ts:export * from "@/schema/<name>". Miss that export and the table never reaches a migration. - For examples, read
auth.ts(tables, relations, indexes) andwaitlist.ts(a minimal non-auth table). - Conventions:
textprimary keys (.$defaultFn(() => crypto.randomUUID())on non-auth tables),timestamp("created_at").defaultNow().notNull(), snake_case columns,onDelete: "cascade"on FKs, and anindex()on every FK column. Both bend for the same kind of column: useonDelete: "set null"when the row outlives the reference and the column is only provenance, and skip the index when nothing queries by it and the table is small enough that the delete-time scan is free. Theconsole.tstables are both: theiractor_idmust not take a rule or a history entry with it when an account is deleted, and although the lists join, search and sort through it, every one of those drives offuser's primary key rather than this column, so an index here would serve only the delete-time sweep. Index a FK when a query narrows on the column itself, or when the table is large enough for the sweep to matter. When aset nullcolumn is the only record of who acted, store the readable text beside it (activity.actor,allowlist.actor) so a row does not become anonymous, and can name an actor that was never an account at all.
2. Generate and review
bun run db:generateRead the generated packages/db/drizzle/NNNN_*.sql. Done when that SQL, its meta/NNNN_snapshot.json, and a new meta/_journal.json entry all appear and the SQL matches the schema edit.
3. Point at a throwaway database first
Local work runs against a disposable container, never the POSTGRES_URL in the root .env. That URL is the shared Neon database, and canary and production both read it, so a migration applied there is applied to production, and a column renamed under running code takes that code down. This is not hypothetical: it has happened, and step 0 and this step both exist because of it.
bunx pglaunch -k # disposable Postgres, -k keeps it across restartsPut the URL it prints in the worktree's own .env as POSTGRES_URL, then migrate and seed into it. The output is colorized, so a script that captures it must strip the escapes first (| sed $'s/\033\\[[0-9;]*m//g'): an escape left on the end of the URL makes drizzle-kit migrate exit 1 with no message at all. One container per worktree, so two branches with different migrations cannot corrupt each other. Two things follow:
- Seed your own fake rows rather than copying real ones. The shared database holds real people, and a screenshot or a response body from it must never reach a PR.
- Applying to the shared database is a deliberate, separately-authorized act. It happens when the change merges, not while it is being built.
4. Apply
bun run db:migrateThis is local or ad-hoc only. On production and canary deploys the API build auto-applies pending migrations (.github/scripts/migrate-on-deploy.ts, gated on VERCEL_ENV/VERCEL_GIT_COMMIT_REF, PR previews skipped), so a migration merged to canary applies itself on the next deploy.
5. Make the running stack see it
bunx turbo run build --filter=@packages/dbThe API consumes @packages/db's built dist. If dev is running and the API imports the new table, restart dev entirely: bun --hot does not pick up new files or exports reliably (see the dev skill).
6. Inspect data
bun run db:studioNotes
POSTGRES_URLcomes from the root.env, which is why step 3 overrides it per worktree: the value that ships in.envis the shared one.- Never edit an applied migration; generate a new one instead.
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.

