preciazo/db-datos/migrate.ts

15 lines
415 B
TypeScript
Raw Normal View History

2023-12-24 21:12:06 +00:00
import Database from "bun:sqlite";
import { drizzle } from "drizzle-orm/bun-sqlite";
import { migrate } from "drizzle-orm/bun-sqlite/migrator";
2023-12-23 23:29:55 +00:00
import * as schema from "./schema.js";
2023-12-26 02:05:50 +00:00
import { DB_PATH } from "./drizzle.config.js";
2023-12-23 23:29:55 +00:00
2023-12-26 03:03:28 +00:00
export function migrateDb() {
const sqlite = new Database(DB_PATH);
const db = drizzle(sqlite, { schema });
2023-12-23 23:29:55 +00:00
2023-12-26 03:03:28 +00:00
migrate(db, { migrationsFolder: "./drizzle" });
2023-12-23 23:29:55 +00:00
2023-12-26 03:03:28 +00:00
sqlite.close();
}