Support schema upgrading with postgres

This commit is contained in:
Ajay Ramachandran
2021-03-01 22:20:44 -05:00
parent 46b42da5bd
commit 88855ab695
3 changed files with 50 additions and 1 deletions

View File

@@ -84,7 +84,7 @@ export class Sqlite implements IDatabase {
Logger.debug('db update: trying ' + path);
while (fs.existsSync(path)) {
Logger.debug('db update: updating ' + path);
db.exec(fs.readFileSync(path).toString());
db.exec(this.processUpgradeQuery(fs.readFileSync(path).toString()));
versionCode = db.prepare("SELECT value FROM config WHERE key = ?").get("version").value;
path = schemaFolder + "/_upgrade_" + fileNamePrefix + "_" + (parseInt(versionCode) + 1) + ".sql";
@@ -92,6 +92,12 @@ export class Sqlite implements IDatabase {
}
Logger.debug('db update: no file ' + path);
}
private static processUpgradeQuery(query: string): string {
let result = query.replace(/^.*--!sqlite-ignore/gm, "");
return result;
}
}
export interface SqliteConfig {