搜索

PythonReactSEOPDF
GitHub Skill

database-development

Database migrations and Drizzle ORM guidelines for the vm0 project

vm0-ai☆ 222 仓库 Stars8 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Database Development

Commands

cd turbo/apps/web

pnpm db:generate   # Generate migration from schema changes
pnpm db:migrate    # Run pending migrations
pnpm db:studio     # Open Drizzle Studio UI

Critical: _journal.json

Manual migrations MUST have an entry in src/db/migrations/meta/_journal.json.

Without this entry, the migration will NOT run and CI will fail.

{
  "idx": 25,                           // Next sequential number
  "version": "7",                      // Always "7"
  "when": 1765000000000,               // Timestamp (ms)
  "tag": "0025_my_migration",          // Must match filename without .sql
  "breakpoints": true
}

Migration Workflows

Auto-Generated (simple changes)
# 1. Edit schema in src/db/schema/
# 2. Generate (auto-updates _journal.json)
pnpm db:generate
# 3. Run locally
pnpm db:migrate
Manual (renames, complex ALTER)
# 1. Create: src/db/migrations/XXXX_name.sql
# 2. Add entry to _journal.json  ← DON'T FORGET!
# 3. Update schema file to match
# 4. Run locally
pnpm db:migrate

Checklist

Before committing:

  • Schema file updated in src/db/schema/
  • Schema exported in src/db/db.ts (if new table)
  • _journal.json updated (manual migrations)
  • pnpm db:migrate works locally
  • pnpm test passes

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-28
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!