add startup db migration in init hook

This commit is contained in:
themodernhakr 2024-12-23 19:43:36 -06:00
parent ce5a87c73a
commit bc0782987a
6 changed files with 10 additions and 0 deletions

View File

View File

View File

View File

View File

@ -0,0 +1,10 @@
import { dev } from '$app/environment';
import { db } from '$lib/server/db';
import type { ServerInit } from '@sveltejs/kit';
import { migrate } from 'drizzle-orm/bun-sqlite/migrator';
export const init: ServerInit = async () => {
if (!dev) {
await migrate(db, { migrationsFolder: './drizzle' });
}
};