Fix migrations failing to run in production build

This commit is contained in:
Dallas Hoffman 2023-09-13 23:48:49 -04:00
parent 8cebb82bae
commit ccdef94727
1 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import { Kysely, Migrator } from 'kysely'; import { Kysely, Migrator } from 'kysely';
import { SQLocalKysely } from 'sqlocal/kysely'; import { SQLocalKysely } from 'sqlocal/kysely';
import type { Schema } from './schema'; import type { Schema } from './schema';
import { migrations } from './migrations/';
const sqlocal = new SQLocalKysely('sticky-notes.db'); const sqlocal = new SQLocalKysely('sticky-notes.db');
const kysely = new Kysely<Schema>({ dialect: sqlocal.dialect }); const kysely = new Kysely<Schema>({ dialect: sqlocal.dialect });
@ -11,7 +12,10 @@ const migrator = new Migrator({
db: kysely, db: kysely,
provider: { provider: {
async getMigrations() { 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; return migrations;
}, },
}, },