ci(deploy): run schema migrations before worker deploy
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 68/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- github-actions, postgresql, typescript
調査の方向性
Start with .github/workflows/deploy.yml and inspect the existing scripts/apply-migration.ts path and the worker's DATABASE_URL secret. Evaluate the preferred Drizzle migration runner against the stated local-development constraints, then verify that migrations run before Deploy worker, are safe to rerun, log their SQL, and block deployment on failure.
索引モデルが issue の本文から書いたものです。
説明
Summary
The deploy workflow ships the worker but never applies pending Drizzle migrations against the Neon database. Today new schema changes land in production only because someone (most recently me) ran npx tsx scripts/apply-migration.ts migrations/<latest>.sql locally against the same connection string the worker uses. That's accidental coupling, not a designed step — a fresh checkout or a forgotten manual apply will let the worker deploy against an outdated schema and silently 500 on any query against the missing tables/columns.
Requirements
- CI applies any pending migrations against
DATABASE_URLbefore theDeploy workerstep runs, so a failing migration blocks the deploy entirely. - Idempotent: re-runs are safe even when no new migrations exist.
- Tracks which migrations have been applied (preferably via Drizzle's
_migrationsjournal in the database, not the localmigrations/meta/_journal.json). - Surfaces the SQL that ran in the workflow log so a failed migration is debuggable from the deploy run alone.
- Uses the same
DATABASE_URLGitHub secret the worker already has access to — no extra credentials. - Local development still works:
npm run db:seedand the existingapply-migration.tsad-hoc path keep functioning for one-off backfills.
Context
Workflow today is .github/workflows/deploy.yml. Order of operations: checkout → install → typecheck → build web → deploy worker → verify worker → deploy web. The migration apply needs to slot in between Install dependencies and Deploy worker so a migration failure aborts before the worker ships.
Recent example: 0007_remarkable_landau.sql (split languages out of skills, with an inline data-move CTE) was generated by drizzle-kit generate and committed to the repo. CI happily deployed the worker on top of it. The new /me/languages endpoints work in production purely because I'd already applied the migration locally against the shared Neon connection ahead of the push.
Future migrations will hit this same trap. If a contributor without access to .dev.vars opens a PR that adds a migration, the merge ships the worker change but leaves the schema unmigrated.
Implementation Notes
Two viable paths:
Option A — drizzle-kit migrate (preferred). Switch to Drizzle's first-party migration runner, which uses a drizzle.__migrations table in the database to track applied migrations. CI runs npx drizzle-kit migrate and skips anything already applied. Requires the runner to know the connection string at build time — already the case via DATABASE_URL secret. Retire scripts/apply-migration.ts for production use, keep it for ad-hoc/local one-shot statements.
Option B — extend apply-migration.ts to detect already-applied migrations (e.g., a migration_history table the script writes to) and apply pending ones in order. Less ecosystem alignment but no new tool to learn.
Option A is the standard path and avoids hand-rolling the journal. Worth converting now while the migration count is small (7 files).
Both options should run against the production DATABASE_URL in CI, fail loudly on migration error, and abort the deploy before the worker ships.
- 主要言語
- HTML
- スター
- 33
- フォーク
- 107
- 平均マージ
- 14時間 6分
- マージ済み PR(30日)
- 19
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
USRSE/usrse.github.io のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
USRSE/usrse.github.io#2117 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 63/100
USRSE/usrse.github.io#2115 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
broken-links
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
USRSE/usrse.github.io#2099 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
USRSE/usrse.github.io#2085 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
USRSE/usrse.github.io#2001 ·
メンテナーはふだん 1 日以内に返信
USRSE/usrse.github.io の issue をすべて見る
似ている issue
-
agent-approved area:configuration size:small
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
RonaldHensbergen/composable-data-stack#1386 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
stephrobert/dsoxlab#413 ·
メンテナーはふだん 1 日以内に返信
-
No scheduled `cargo deny` / `npm audit` run: new advisories on locked dependencies go unnoticedオープンenhancement good first issue P3
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
NakileSolutions/Steno#260 ·
メンテナーはふだん 1 日以内に返信
-
Broken linksオープンci
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
tomgreef/dj-toolkit#187 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100