File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4747 "typecheck" : " tsc --noEmit -p ." ,
4848 "test" : " bun test" ,
4949 "db:generate" : " drizzle-kit generate --config=./src/db/drizzle.config.ts" ,
50- "db:migrate" : " drizzle-kit push --config=./src/db/drizzle.config.ts" ,
50+ "db:migrate" : " drizzle-kit migrate --config=./src/db/drizzle.config.ts" ,
5151 "db:start" : " docker compose -f ./src/db/docker-compose.yml up --wait && bun run db:generate && (timeout 1 || sleep 1) && bun run db:migrate" ,
5252 "db:e2e:setup" : " bun ./src/db/e2e-setup.ts" ,
5353 "db:e2e:down" : " docker compose -f ./src/db/docker-compose.e2e.yml down --volumes" ,
Original file line number Diff line number Diff line change 1+ -- One-time bootstrap for environments that were previously managed by
2+ -- `drizzle-kit push` and are now switching to `drizzle-kit migrate`.
3+ --
4+ -- `drizzle-kit migrate` skips any migration whose `when` (from
5+ -- meta/_journal.json) is <= the max `created_at` in
6+ -- drizzle.__drizzle_migrations. Inserting a single row whose `created_at`
7+ -- matches the last-already-applied migration's `when` tells drizzle "every
8+ -- migration up to and including this one is already applied", so only new
9+ -- migrations run on the next deploy.
10+ --
11+ -- Run this exactly once per environment (prod, staging, local dev DB that
12+ -- was set up via push). Skip it on a fresh database — `drizzle-kit migrate`
13+ -- will apply all migrations from scratch there.
14+ --
15+ -- 1776719872222 = `when` of 0044_violet_stingray in meta/_journal.json.
16+ -- If you bootstrap a new environment after further migrations have landed,
17+ -- update the value to the latest applied migration's `when`.
18+
19+ CREATE SCHEMA IF NOT EXISTS drizzle;
20+
21+ CREATE TABLE IF NOT EXISTS drizzle .__drizzle_migrations (
22+ id SERIAL PRIMARY KEY ,
23+ hash text NOT NULL ,
24+ created_at bigint
25+ );
26+
27+ INSERT INTO drizzle .__drizzle_migrations (hash, created_at)
28+ SELECT ' bootstrap-from-push' , 1776719872222
29+ WHERE NOT EXISTS (SELECT 1 FROM drizzle .__drizzle_migrations );
You can’t perform that action at this time.
0 commit comments