database-schema-changes
Skill130 starsChanged 5 days agoMITView on GitHub
Guide for making database schema changes in Platypus using Drizzle ORM — editing the schema, pushing to a dev database, and generating the migration that ships.
In this repository38 other files it gives its agents.
- .agents/skills/humanizer/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-api-endpointSkill
- api-conventionsSkill
- ask-mattSkill
- card-conventionsSkill
- codebase-designSkill
- code-reviewSkill
- diagnosing-bugsSkill
- docs-auditSkill
- domain-modelingSkill
- form-conventionsSkill
- grillingSkill
- grill-meSkill
- grill-with-docsSkill
- handoffSkill
- humanizerSkill
- implementSkill
- implement-specSkill
- improve-codebase-architectureSkill
- platypus-toolsSkill
- pre-release-checkSkill
- prototypeSkill
- prSkill
- researchSkill
- retroSkill
- setup-matt-pocock-skillsSkill
- tddSkill
- teachSkill
- to-questionnaireSkill
- to-specSkill
- to-ticketsSkill
- triageSkill
- ui-conventionsSkill
- wait-whatSkill
- wayfinderSkill
- wizardSkill
- writing-for-agentsSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 64
When both migrations are unreleased and you are integrating the branches yourself, combining them into one is cleaner than stacking two:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Database Schema Changes
Push is for your machine; generate is what ships. Both, every time. A push with no generate leaves a dev database that works and a production deploy that never receives the change — and nothing local tells you, because your own database is already correct.
Steps
- Edit the schema — the backend's Drizzle schema module, where the tables are declared.
Push it to your dev database. Needs
pnpm devup, since the push talks to a live Postgres:pnpm drizzle-kit-pushGenerate the migration. Production applies numbered
.sqlmigrations, not your schema file, so this is the step that carries the change out of your machine:pnpm drizzle-kit-generate
Done when git status shows three new or modified artefacts beside your
schema edit: a numbered .sql migration, its snapshot, and an appended journal
entry. All of them are committed, in the same commit as the schema change.
Data changes
Generate writes DDL — it reads your schema and diffs it. A backfill, a re-shaping of existing rows, or anything else that needs to reason about data is yours to write into the generated migration by hand.
Dev never runs it: the push flow applies DDL only and skips migration files
entirely, so a hand-written backfill is invisible until production. Run the
migration file against the dev container (apps/backend/scripts/start_postgres.sh
names it and its credentials):
docker exec -i platypus-postgres psql -U postgres -d postgres \
-v ON_ERROR_STOP=1 -1 < apps/backend/drizzle/<tag>.sqlThe PR body states that the migration carries a data step push skips, so
every reviewer knows to apply it to their own database.
Migration number collisions
Main gained a migration with your number since you generated (parallel
branches each generate the next free number). The fix is regeneration, not
hand-renumbering: take main's migrations, discard your generated .sql,
snapshot and journal entry, and run step 3 again. Copy any hand-written data
SQL into the new file, and update tests that name the migration tag.
When both migrations are unreleased and you are integrating the branches yourself, combining them into one is cleaner than stacking two:
- one
.sqlholding both changes, statements separated by--> statement-breakpoint, named for both; - the snapshot from whichever side has DDL (data-only migrations change none);
- one journal entry carrying the combined tag.
Done when the newest snapshot's prevId equals the previous snapshot's
id, and pnpm drizzle-kit-generate prints "No schema changes".
Auth tables
better-auth owns the auth tables — do not hand-edit that generated schema. When you change the auth configuration, regenerate it, then treat the result as a normal schema change and continue from step 2:
pnpm --dir apps/backend dlx @better-auth/cli@1.4.21 generate \
--config ./src/auth.ts --output ./src/db/auth-schema.ts --yes(The paths inside that command are arguments the CLI needs, not references to look up.)
The CLI rewrites the whole file and can revert unrelated defaults (seen with
role and updatedAt). Diff the result and keep only the lines your change
needs.
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.

