Skip to content

Commit 9371cc7

Browse files
committed
add migration to run script
1 parent 417771a commit 9371cc7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/core/src/db/migrator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { promises } from "node:fs";
33
import { FileMigrationProvider, Migrator } from "kysely";
44
import { db, destroyKyselyDb, initKyselyDb } from "./database.ts";
55

6-
async function migrateToLatest() {
6+
export async function migrateToLatest() {
77
const migrator = new Migrator({
88
db,
99
provider: new FileMigrationProvider({

packages/core/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { initKyselyDb } from "./db/database.ts";
22
import api from "./api/index.ts";
3+
import { migrateToLatest } from "./db/migrator.ts";
34

45
initKyselyDb();
56

7+
console.info("Migrating database to latest version...");
8+
await migrateToLatest();
9+
console.info("Database migrated to latest version");
10+
11+
console.info("Starting server...");
612
const port = 4000;
713
api.listen({ port });
814
console.info(`Server is running on port http://localhost:${port}`);

0 commit comments

Comments
 (0)