db-migrations

Generate Drizzle migration SQL and sync journal, snapshots, and schema documentation.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/kingheu0818-sketch/lobehub_yu --skill db-migrations-kingheu0818-sketch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: db-migrations
Source: https://github.com/kingheu0818-sketch/lobehub_yu/tree/main/.agents/skills/db-migrations
Command: npx skills add https://github.com/kingheu0818-sketch/lobehub_yu --skill db-migrations-kingheu0818-sketch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you create and maintain correct Drizzle migration files without breaking the migration journal, especially when regenerating after schema changes, resolving migration order conflicts, or renaming migrations.

Core Features & Use Cases

  • Generate Drizzle migrations consistently: Produces new migration SQL plus the required journal and snapshot updates for Drift/Drizzle compatibility.
  • Support custom migrations: Enables non-schema operations (like PostgreSQL extensions) via a custom generation workflow that still updates migration metadata.
  • Make SQL safely re-runnable: Guides defensive, idempotent patterns for CREATE TABLE, ALTER TABLE, and DROP operations to reduce re-run failures.
  • Keep migration history accurate: Ensures the journal tag matches the renamed migration file so the migration timeline stays coherent.

Quick Start

Use this Skill when you need to generate or regenerate Drizzle migration SQL, then rename the migration file to a meaningful name while updating the journal tag accordingly.

Frequently Asked Questions about db-migrations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I regenerate Drizzle migrations after renaming files without breaking the journal?

To regenerate Drizzle migrations safely after renaming files, update the _journal.json tag and snapshots to reflect the final filename, ensuring the migration timeline stays coherent and preventing broken migration history.

How do I resolve database migration conflicts after a git rebase?

To resolve migration sequence conflicts after rebases, regenerate the Drizzle migration SQL and ensure the migration journal and snapshots accurately reflect the corrected sequence, restoring timeline integrity.

How do I write idempotent SQL for Drizzle database migrations?

Writing idempotent SQL for Drizzle database migrations involves applying defensive patterns to CREATE TABLE, ALTER TABLE, and DROP operations, reducing re-run failures and making migration SQL safely re-runnable.

Can I use drizzle-kit to generate custom migrations for PostgreSQL extensions?

Yes, you can use drizzle-kit generate to create custom migrations for non-schema operations like PostgreSQL extensions, applying a custom workflow that still updates the required migration metadata and journal.

Why does my Drizzle migration history break after renaming migration files?

Drizzle migration history breaks after renaming files because the _journal.json tag and snapshots no longer match the new filename, requiring you to update the journal tag accordingly to maintain a coherent migration timeline.