mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
database upgrade fixes
This commit is contained in:
@@ -4,11 +4,17 @@ import sqliteService from '../sqlite.js';
|
|||||||
|
|
||||||
const tableFixes = {
|
const tableFixes = {
|
||||||
async cleanLegendFromFriendLog() {
|
async cleanLegendFromFriendLog() {
|
||||||
|
var tables = [];
|
||||||
|
await sqliteService.execute((dbRow) => {
|
||||||
|
tables.push(dbRow[0]);
|
||||||
|
}, `SELECT name FROM sqlite_schema WHERE type='table' AND name LIKE '%_friend_log_history'`);
|
||||||
|
for (var tableName of tables) {
|
||||||
await sqliteService.executeNonQuery(
|
await sqliteService.executeNonQuery(
|
||||||
`DELETE FROM ${dbVars.userPrefix}_friend_log_history
|
`DELETE FROM ${tableName}
|
||||||
WHERE type = 'TrustLevel' AND created_at > '2022-05-04T01:00:00.000Z'
|
WHERE type = 'TrustLevel' AND created_at > '2022-05-04T01:00:00.000Z'
|
||||||
AND ((trust_level = 'Veteran User' AND previous_trust_level = 'Trusted User') OR (trust_level = 'Trusted User' AND previous_trust_level = 'Veteran User'))`
|
AND ((trust_level = 'Veteran User' AND previous_trust_level = 'Trusted User') OR (trust_level = 'Trusted User' AND previous_trust_level = 'Veteran User'))`
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async fixGameLogTraveling() {
|
async fixGameLogTraveling() {
|
||||||
@@ -111,21 +117,39 @@ const tableFixes = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async fixBrokenNotifications() {
|
async fixBrokenNotifications() {
|
||||||
|
var tables = [];
|
||||||
|
await sqliteService.execute((dbRow) => {
|
||||||
|
tables.push(dbRow[0]);
|
||||||
|
}, `SELECT name FROM sqlite_schema WHERE type='table' AND name LIKE '%_notifications'`);
|
||||||
|
for (var tableName of tables) {
|
||||||
await sqliteService.executeNonQuery(
|
await sqliteService.executeNonQuery(
|
||||||
`DELETE FROM ${dbVars.userPrefix}_notifications WHERE (created_at is null or created_at = '')`
|
`DELETE FROM ${tableName} WHERE (created_at is null or created_at = '')`
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async fixBrokenGroupChange() {
|
async fixBrokenGroupChange() {
|
||||||
|
var tables = [];
|
||||||
|
await sqliteService.execute((dbRow) => {
|
||||||
|
tables.push(dbRow[0]);
|
||||||
|
}, `SELECT name FROM sqlite_schema WHERE type='table' AND name LIKE '%_notifications'`);
|
||||||
|
for (var tableName of tables) {
|
||||||
await sqliteService.executeNonQuery(
|
await sqliteService.executeNonQuery(
|
||||||
`DELETE FROM ${dbVars.userPrefix}_notifications WHERE type = 'groupChange' AND created_at < '2024-04-23T03:00:00.000Z'`
|
`DELETE FROM ${tableName} WHERE type = 'groupChange' AND created_at < '2024-04-23T03:00:00.000Z'`
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async fixCancelFriendRequestTypo() {
|
async fixCancelFriendRequestTypo() {
|
||||||
|
var tables = [];
|
||||||
|
await sqliteService.execute((dbRow) => {
|
||||||
|
tables.push(dbRow[0]);
|
||||||
|
}, `SELECT name FROM sqlite_schema WHERE type='table' AND name LIKE '%_friend_log_history'`);
|
||||||
|
for (var tableName of tables) {
|
||||||
await sqliteService.executeNonQuery(
|
await sqliteService.executeNonQuery(
|
||||||
`UPDATE ${dbVars.userPrefix}_friend_log_history SET type = 'CancelFriendRequest' WHERE type = 'CancelFriendRequst'`
|
`UPDATE ${tableName} SET type = 'CancelFriendRequest' WHERE type = 'CancelFriendRequst'`
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async getBrokenGameLogDisplayNames() {
|
async getBrokenGameLogDisplayNames() {
|
||||||
|
|||||||
@@ -885,7 +885,6 @@ export const useAuthStore = defineStore('Auth', () => {
|
|||||||
await database.initUserTables(userStore.currentUser.id);
|
await database.initUserTables(userStore.currentUser.id);
|
||||||
watchState.isLoggedIn = true;
|
watchState.isLoggedIn = true;
|
||||||
AppApi.CheckGameRunning(); // restore state from hot-reload
|
AppApi.CheckGameRunning(); // restore state from hot-reload
|
||||||
vrcxStore.updateDatabaseVersion();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
+2
-1
@@ -103,6 +103,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
'VRCX_databaseVersion',
|
'VRCX_databaseVersion',
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
updateDatabaseVersion();
|
||||||
|
|
||||||
clearVRCXCacheFrequency.value = await configRepository.getInt(
|
clearVRCXCacheFrequency.value = await configRepository.getInt(
|
||||||
'VRCX_clearVRCXCacheFrequency',
|
'VRCX_clearVRCXCacheFrequency',
|
||||||
@@ -193,7 +194,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
|
|
||||||
async function updateDatabaseVersion() {
|
async function updateDatabaseVersion() {
|
||||||
// requires dbVars.userPrefix to be already set
|
// requires dbVars.userPrefix to be already set
|
||||||
const databaseVersion = 12;
|
const databaseVersion = 13;
|
||||||
let msgBox;
|
let msgBox;
|
||||||
if (state.databaseVersion < databaseVersion) {
|
if (state.databaseVersion < databaseVersion) {
|
||||||
if (state.databaseVersion) {
|
if (state.databaseVersion) {
|
||||||
|
|||||||
Reference in New Issue
Block a user