sqlite multi-statement upgrade fix

This commit is contained in:
Essem 2022-10-25 15:38:20 -05:00
parent 5d679dbb7a
commit a67c2b9884
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C

View file

@ -54,7 +54,9 @@ export async function upgrade(logger) {
while (version < (sqliteUpdates.length - 1)) { while (version < (sqliteUpdates.length - 1)) {
version++; version++;
logger.warn(`Running version ${version} update script (${sqliteUpdates[version]})...`); logger.warn(`Running version ${version} update script (${sqliteUpdates[version]})...`);
connection.prepare(sqliteUpdates[version]).run(); for (const statement of sqliteUpdates[version].split("\n")) {
connection.prepare(statement).run();
}
} }
connection.pragma(`user_version = ${version}`); // insecure, but the normal templating method doesn't seem to work here connection.pragma(`user_version = ${version}`); // insecure, but the normal templating method doesn't seem to work here
connection.prepare("COMMIT").run(); connection.prepare("COMMIT").run();