19 lines
562 B
TypeScript
19 lines
562 B
TypeScript
|
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)
|
||
|
}
|
||
|
}
|