chromatic/server/migrations.ts

13 lines
365 B
TypeScript
Raw Normal View History

2024-02-12 12:15:50 +00:00
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;");
}