From ccdef94727810be26e796998a0a3950c41685033 Mon Sep 17 00:00:00 2001 From: Dallas Hoffman Date: Wed, 13 Sep 2023 23:48:49 -0400 Subject: [PATCH] Fix migrations failing to run in production build --- src/lib/db/client.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/db/client.ts b/src/lib/db/client.ts index 7898963..cafd424 100644 --- a/src/lib/db/client.ts +++ b/src/lib/db/client.ts @@ -1,6 +1,7 @@ import { Kysely, Migrator } from 'kysely'; import { SQLocalKysely } from 'sqlocal/kysely'; import type { Schema } from './schema'; +import { migrations } from './migrations/'; const sqlocal = new SQLocalKysely('sticky-notes.db'); const kysely = new Kysely({ dialect: sqlocal.dialect }); @@ -11,7 +12,10 @@ const migrator = new Migrator({ db: kysely, provider: { async getMigrations() { - const { migrations } = await import('./migrations/'); + // TODO: Dynamic import does not work in production build + // because the imported chunk imports `sql` from the same + // chunk that imports it, so circular dependency. Vite bug. + // const { migrations } = await import('./migrations/'); return migrations; }, },