fix: ensure __migration table exists
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Martti Malmi 2024-02-07 11:04:58 +02:00
parent 2f0b4f8d96
commit 248b35d3ca

View File

@ -15,6 +15,12 @@ const migrations = [
async function migrate(relay: SqliteRelay) {
if (!relay.db) throw new Error("DB must be open");
relay.db.exec(
"CREATE TABLE IF NOT EXISTS __migration (\
version INTEGER PRIMARY KEY, \
migrated_at INTEGER \
)",
);
const res = relay.db.exec("SELECT MAX(version) FROM __migration", { returnValue: "resultRows" });
let currentVersion = (res[0][0] as number | undefined) ?? 0;