drizzle-migration-conflict-resolutionlisted
Install: claude install-skill wordbricks/onequery
# DB Migration Conflict Resolution
## Goal
Resolve Drizzle migration conflicts without manually editing migration SQL or `meta/_journal.json`.
## Workflow
1. 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.
2. Fetch the base branch.
- Run `git fetch origin`.
- Default to `origin/main` unless the user requests another base branch.
3. 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`.
4. Find local-only migration artifacts.
- Run:
```bash
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.
5. 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.
6. Regenerate migration chain from schema.
- Run `cd packages/db && bun run db:generate`.
- Let Drizzle regenerate the next migration and update `meta/_journal.json`.
7. Stage and verify.
- Run `git add packages/db/src/migrations packages/db/src/migrations/meta/_journal.json`.
- Confirm no conflict markers remain:
```bash
rg -n "^(<<