learn-request-queue/src/version.ts

19 lines
562 B
TypeScript
Raw Normal View History

2020-11-01 20:47:47 +00:00
import * as queries from "./queries";
import pg from "pg";
import db from "./db";
var versionMajor = 0;
var versionMinor = 1;
var versionPatch = 0;
export function getVersion() {
return `${versionMajor}.${versionMinor}.${versionPatch}`
}
export async function checkVersion() {
var dbver = await db.query(queries.getDbVersion).then((result: pg.QueryResult) => result.rows[0]['get_version']);
if (dbver != `${versionMajor}.${versionMinor}`) {
throw new Error("Version mismatch!\nApplication version: " + getVersion() + "\nDatabase version: " + dbver)
}
}