본문으로 건너뛰기
cccskills
무료GitHub에 공개

rebase-drizzle-migration

Repair conflicting Drizzle migrations after a rebase by inspecting migration history, SQL files, and schema snapshots. The skill guides cleanup, regeneration of database change scripts, local application, and verification against the upstream branch.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

fix drizzle migrations after rebasing onto upstream/main when migrations diverged

실행 점수 미검증

설치 방법 보기

이럴 때 유용합니다

  • Repairing conflicting migrations after a rebase
  • Removing duplicate migration history entries
  • Regenerating migrations for intended schema changes
  • Investigating unexpected column rename prompts

포함된 파일(1)

  • SKILL.md5.7 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Rebase Drizzle Migration

Guide the user through recovering from a messy drizzle migration state after rebasing onto upstream/main.

Agent Workflow

  1. Diagnose - Analyze the current state and identify what's wrong
  2. Explain - Tell the user what happened and why
  3. Fix - Run the necessary commands to fix the migration state
  4. Verify - Check results after each step

Diagnosis Phase

When this skill is invoked, first diagnose the problem:

# Check for duplicate journal entries
cat packages/db/drizzle/meta/_journal.json | tail -30

# List migration files
ls packages/db/drizzle/*.sql

# Check diff against upstream
git diff upstream/main --stat -- packages/db/

# Check what upstream has
git show upstream/main:packages/db/drizzle/meta/_journal.json | tail -20

# Find the merge base
git merge-base HEAD upstream/main

Look for:

  • Duplicate idx values in journal
  • Same migration tag appearing twice
  • Migration files that exist on branch but not upstream (or vice versa)
  • Schema files that don't match upstream's expected state

The Problem (Explain to User)

Drizzle migrations are sequential and tracked in packages/db/drizzle/meta/_journal.json. The issue occurs when:

  1. You branched off main at migration 0008
  2. You added your own migration 0009 (or overwrote 0008)
  3. Meanwhile, upstream added their own 0009
  4. You rebased onto upstream

This results in:

  • Conflicting or duplicate migration files
  • A corrupted journal with duplicate entries or wrong indices
  • Snapshot files that don't match the journal
  • drizzle-kit generate asking nonsensical questions about column renames

Fix Process


Step 1: Checkout upstream/main

Switch to upstream/main to get a clean database state:

git checkout upstream/main

Step 2: Apply migrations to database

Run the migration command:

bun --bun --cwd packages/db drizzle-kit migrate

Step 3: Switch back to feature branch

Switch back to the feature branch:

git checkout <branch-name>

Step 4: Clean up migration artifacts

Run cleanup commands:

# Identify what needs cleanup by checking diff
git diff upstream/main --stat -- packages/db/drizzle/

# Check current journal state
cat packages/db/drizzle/meta/_journal.json | tail -20

Then perform cleanup:

  • Remove migration SQL files the branch added: rm packages/db/drizzle/0010_*.sql
  • Remove corresponding snapshots: rm packages/db/drizzle/meta/0010_snapshot.json
  • Restore journal from upstream: git checkout upstream/main -- packages/db/drizzle/meta/_journal.json
  • Restore any accidentally modified snapshots: git checkout upstream/main -- packages/db/drizzle/meta/0009_snapshot.json
  • Restore schema files that should match upstream (files user didn't intentionally modify)

Step 5: Verify clean state

Run verification:

git diff upstream/main --stat -- packages/db/

The diff should now show ONLY schema file changes (e.g., sessions.ts), not migration files.


Step 6: reseet database state

Ask the user (DO NOT DO THIS YOURSELF UNLESS YOU ARE ASKED TO DO SO) to reset the database state to the upstream/main state.

# reset the database volumes
docker compose down -v && docker compose up -d

# then seed the existing migrations
bun --bun --cwd packages/db drizzle-kit migrate

This will delete all data in the local database and re-apply the upstream migrations.


Step 7: Regenerate migration

Generate a fresh migration for the schema changes:

bun run db:migrations:generate

This should create a new migration file (e.g., 0010_something.sql) with just the changes.


Step 8: Apply migration locally

Apply the new migration to the local database:

bun --bun --cwd packages/db drizzle-kit migrate

Step 9: Verify and commit

After migration succeeds, verify:

# Check the final diff
git diff upstream/main --stat -- packages/db/

# Run typecheck
bun run typecheck

# Run tests
bun --bun run test

The diff should show:

  • The new migration SQL file
  • The new snapshot JSON
  • Updated journal
  • Schema file changes

Troubleshooting

If drizzle-kit asks about column renames during generate

The schema doesn't match what drizzle expects. Check if:

  • Schema files were accidentally reverted during rebase
  • Upstream renamed columns that your schema still has with old names

Fix: git checkout upstream/main -- packages/db/src/tables/<file>.ts for files you didn't intend to modify.

If journal still has duplicates after cleanup

The checkout didn't work or there are staged changes. Run:

git checkout upstream/main -- packages/db/drizzle/meta/_journal.json

If local DB is in weird state

Run migrate on upstream/main again, then switch back to branch.

Key Files Reference

  • packages/db/drizzle/*.sql - Migration SQL files (sequential: 0000, 0001, ...)
  • packages/db/drizzle/meta/_journal.json - Tracks all migrations and their order
  • packages/db/drizzle/meta/NNNN_snapshot.json - Schema snapshot after each migration
  • packages/db/src/tables/*.ts - Drizzle schema definitions

Commands Reference (for agent)

# All commands are non-interactive and safe for agent to run:
git diff upstream/main --stat -- packages/db/
git show upstream/main:packages/db/drizzle/meta/_journal.json
cat packages/db/drizzle/meta/_journal.json
ls packages/db/drizzle/*.sql
git checkout upstream/main -- <file>  # restore specific file
rm packages/db/drizzle/0010_*.sql     # cleanup
bun run db:migrations:generate
bun --bun --cwd packages/db drizzle-kit migrate

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Automate website navigation, form entry, and clicks through a browser command line tool. Extract page text, capture screenshots, and compare page states to check interactions or test web app behavior across screen sizes.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Automate form entry and button clicks
  • Extract text from web pages
  • Save page screenshots and PDFs
humanlayer/humanlayer1.2만2026년 10월 25일 업데이트

Rewrite dense or ambiguous English into short, direct sentences using principles from ASD-STE100, a standard for clear technical English. It preserves facts and conditions, identifies writing issues, and shows the original and revised text side by side.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Clarifying English instructions for another agent
  • Simplifying English tool descriptions and error messages
  • Making English easier for non-native readers
humanlayer/humanlayer1.2만2026년 10월 25일 업데이트

Inspect GitHub pull requests, read review conversations, and investigate failed automated checks with dedicated scripts. Get consolidated status reports, unresolved discussion threads, and failing job or step logs, with full logs saved for further inspection.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Checking pull request status in one report
  • Reading unresolved review conversations
  • Investigating failed CI jobs and steps
humanlayer/humanlayer1.2만2026년 10월 25일 업데이트

Update release base versions for supported packages, keep matching version fields in sync, and verify generated versions. The workflow covers committing and pushing the changes, with guidance for release steps after merging.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Prepare a package version update for release
  • Synchronize version fields across related files
  • Verify generated versions before pushing
humanlayer/humanlayer1.2만2026년 10월 25일 업데이트

calldiff

무료

Compare function call structures across Git commits, branches, or working files to support code review. Display call trees and trace paths from an entry function to a target function, with support for 22 languages.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Compare function calls before and after a change
  • Review call structure changes between branches
  • Trace paths from an entry function to a target
humanlayer/humanlayer1.2만2026년 10월 25일 업데이트

Automate browser tasks from the terminal using the chrome-devtools-mcp CLI. Inspect page elements, click and fill forms, navigate tabs, capture screenshots, and investigate network requests, console messages, performance, and memory through shell commands.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Automating form input and page navigation
  • Capturing page or element screenshots
  • Investigating network requests and console errors
humanlayer/humanlayer1.2만2026년 10월 25일 업데이트

humanlayer의 스킬 모두 보기

이 스킬의 문제 신고