mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2026-01-28 13:20:48 +03:00
Support schema upgrading with postgres
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user