drizzle-migration-conflict-resolution
Skill17 starsChanged 7 months agoApache-2.0View on GitHub
Resolve Drizzle migration merge/rebase conflicts in OneQuery by rewinding local-only migration history and regenerating migration metadata. Use when conflicts involve packages/db/src/migrations/meta/_journal.json, migration SQL files in packages/db/src/migrations/*.sql, or migration snapshots in packages/db/src/migrations/meta/*_snapshot.json.
In this repository19 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-browserSkill
- agentic-legibilitySkill
- babysit-prSkill
- better-result-adoptSkill
- code-breaking-changesSkill
- code-review-change-sizeSkill
- code-reviewSkill
- code-review-testingSkill
- gh-pr-writingSkill
- knip-deadcodeSkill
- onequery-blog-imagesSkill
- onequery-bugSkill
- onequery-pr-bodySkill
- protobufSkill
- react-no-use-effectSkill
- tanstack-query-best-practicesSkill
- tanstack-router-best-practicesSkill
- xstateSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 7 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
If non-migration conflicts need product decisions, stop and ask the user.
- Very specific: line 19
Default to origin/main unless the user requests another base branch.
- Distinctive: line 21
Keep incoming journal history as baseline.
- Very specific: line 23
Do not hand-edit packages/db/src/migrations/meta/_journal.json.
- Distinctive: line 31
Treat returned SQL and snapshot files as local-only migration history.
- Distinctive: line 33
Remove local-only migration artifacts.
- Very specific: line 34
Run git rm <each-local-only-file> for returned migration SQL and snapshot files.
- Distinctive: line 35
Keep incoming branch migration files intact.
- Distinctive: line 51
If pre-commit/pre-push hooks rewrite migration metadata formatting, commit the formatted files so the branch is clean.
- Very specific: line 54
Never manually create or edit files inside packages/db/src/migrations/.
- Very specific: line 55
Never manually edit packages/db/src/migrations/meta/_journal.json.
- Distinctive: line 57
If generated migration includes unexpected schema changes, stop and ask the user before committing.
≈ “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
DB Migration Conflict Resolution
Goal
Resolve Drizzle migration conflicts without manually editing migration SQL or meta/_journal.json.
Workflow
- Inspect conflict scope.
- Run
git status --short. - Confirm the migration conflict includes
packages/db/src/migrations/meta/_journal.json. - If non-migration conflicts need product decisions, stop and ask the user.
- Fetch the base branch.
- Run
git fetch origin. - Default to
origin/mainunless the user requests another base branch.
- Keep incoming journal history as baseline.
- Run
git checkout --theirs packages/db/src/migrations/meta/_journal.json. - Do not hand-edit
packages/db/src/migrations/meta/_journal.json.
- Find local-only migration artifacts.
- Run:
comm -23 <(git ls-tree -r --name-only HEAD packages/db/src/migrations | sort) \
<(git ls-tree -r --name-only origin/main packages/db/src/migrations | sort)- Treat returned SQL and snapshot files as local-only migration history.
- Remove local-only migration artifacts.
- Run
git rm <each-local-only-file>for returned migration SQL and snapshot files. - Keep incoming branch migration files intact.
- Regenerate migration chain from schema.
- Run
cd packages/db && bun run db:generate. - Let Drizzle regenerate the next migration and update
meta/_journal.json.
- Stage and verify.
- Run
git add packages/db/src/migrations packages/db/src/migrations/meta/_journal.json. - Confirm no conflict markers remain:
rg -n "^(<<<<<<<|=======|>>>>>>>)" packages/db/src/migrations/meta/_journal.json- Inspect generated SQL and verify it reflects expected schema deltas only.
- Finalize merge/rebase.
- Continue merge/rebase flow with
git commitorgit rebase --continue. - If pre-commit/pre-push hooks rewrite migration metadata formatting, commit the formatted files so the branch is clean.
Guardrails
- Never manually create or edit files inside
packages/db/src/migrations/. - Never manually edit
packages/db/src/migrations/meta/_journal.json. - Regenerate via
bun run db:generateafter history rewind. - If generated migration includes unexpected schema changes, stop and ask the user before committing.
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.

