fix: use bun-sqlite migrator instead of drizzle-kit push in Docker
drizzle-kit push depends on better-sqlite3 which isn't supported in Bun, causing migrations to fail and the server to crash-loop in prod. Replace with drizzle-orm/bun-sqlite/migrator that applies the existing SQL migration files using the native bun:sqlite driver. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
bun run db:push
|
bun run src/db/migrate.ts
|
||||||
exec bun run src/server/index.ts
|
exec bun run src/server/index.ts
|
||||||
|
|||||||
13
src/db/migrate.ts
Normal file
13
src/db/migrate.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { Database } from "bun:sqlite";
|
||||||
|
import { drizzle } from "drizzle-orm/bun-sqlite";
|
||||||
|
import { migrate } from "drizzle-orm/bun-sqlite/migrator";
|
||||||
|
|
||||||
|
const sqlite = new Database(process.env.DATABASE_PATH || "gearbox.db");
|
||||||
|
sqlite.run("PRAGMA journal_mode = WAL");
|
||||||
|
sqlite.run("PRAGMA foreign_keys = ON");
|
||||||
|
|
||||||
|
const db = drizzle(sqlite);
|
||||||
|
migrate(db, { migrationsFolder: "./drizzle" });
|
||||||
|
|
||||||
|
sqlite.close();
|
||||||
|
console.log("Migrations applied successfully");
|
||||||
Reference in New Issue
Block a user