K
Kysely12mo ago
mdthansil

How can I use Kysely migration inside NextJS 13 project?

I created a folder called kysely in root directory of next js then created a migrator.ts which contains migration code (Migrator) and created a folder inside kysely folder called migrations then I placed all migrations in it. I tried to run the migrator.ts file with ts-node but it's throwing some module import issues (cannot use import module outside a module) how can I run migration in nextjs
Solution:
Fixed the issue by replacing ts-node with tsx and also changed migrationFolder path to absolute path ```typescript const migrator = new Migrator({...
Jump to solution
1 Reply
Solution
mdthansil
mdthansil12mo ago
Fixed the issue by replacing ts-node with tsx and also changed migrationFolder path to absolute path
const migrator = new Migrator({
db,
provider: new FileMigrationProvider({
fs,
path,
migrationFolder: path.resolve(path.join(__dirname, 'migrations')),
}),
});
const migrator = new Migrator({
db,
provider: new FileMigrationProvider({
fs,
path,
migrationFolder: path.resolve(path.join(__dirname, 'migrations')),
}),
});