Merge pull request #2422 from Bilb/fix-friendrequeststatus-migration-failed

fix: drop column friendRequestStatus if exists
This commit is contained in:
Audric Ackermann 2022-08-16 13:52:24 +10:00 committed by GitHub
commit 67153bbb07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -77,6 +77,7 @@ const LOKI_SCHEMA_VERSIONS = [
updateToSessionSchemaVersion25,
updateToSessionSchemaVersion26,
updateToSessionSchemaVersion27,
updateToSessionSchemaVersion28,
];
function updateToSessionSchemaVersion1(currentVersion: number, db: BetterSqlite3.Database) {
@ -1143,6 +1144,28 @@ function updateToSessionSchemaVersion27(currentVersion: number, db: BetterSqlite
console.info(
'removing lastMessageDeletedServerID & lastMessageFetchedServerID from rooms table. done'
);
writeSessionSchemaVersion(targetVersion, db);
console.log('... done');
})();
console.log(`updateToSessionSchemaVersion${targetVersion}: success!`);
}
function updateToSessionSchemaVersion28(currentVersion: number, db: BetterSqlite3.Database) {
const targetVersion = 28;
if (currentVersion >= targetVersion) {
return;
}
console.log(`updateToSessionSchemaVersion${targetVersion}: starting...`);
// some very old databases have the column friendRequestStatus still there but we are not using it anymore. So drop it if we find it.
db.transaction(() => {
const rows = db.pragma(`table_info(${CONVERSATIONS_TABLE});`);
if (rows.some((m: any) => m.name === 'friendRequestStatus')) {
console.info('found column friendRequestStatus. Dropping it');
db.exec(`ALTER TABLE ${CONVERSATIONS_TABLE} DROP COLUMN friendRequestStatus;`);
}
writeSessionSchemaVersion(targetVersion, db);
console.log('... done');
})();