chromatic/server/migrations.ts

12 lines
365 B
TypeScript

import { Database } from "bun:sqlite";
export function migrateDatabase(db: Database) {
const version = (db.query("PRAGMA user_version").get() as { user_version: number }).user_version;
if (version < 1) {
console.log("Applying migration 0 -> 1")
db.run("CREATE TABLE tokens (id TEXT, token TEXT, PRIMARY KEY(id))")
}
db.run("PRAGMA user_version = 1;");
}