mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 14:46:04 +02:00
Fix database upgrade
This commit is contained in:
@@ -65,14 +65,22 @@ const tableAlter = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async updateTableForAvatarHistory() {
|
async updateTableForAvatarHistory() {
|
||||||
|
var tables = [];
|
||||||
await sqliteService.execute((dbRow) => {
|
await sqliteService.execute((dbRow) => {
|
||||||
const columnExists = dbRow.some((row) => row.name === 'time');
|
tables.push(dbRow[0]);
|
||||||
if (!columnExists) {
|
}, `SELECT name FROM sqlite_schema WHERE type='table' AND name LIKE '%_avatar_history'`);
|
||||||
sqliteService.executeNonQuery(
|
for (var tableName of tables) {
|
||||||
`ALTER TABLE ${dbVars.userPrefix}_avatar_history ADD time INTEGER DEFAULT 0`
|
try {
|
||||||
|
await sqliteService.executeNonQuery(
|
||||||
|
`ALTER TABLE ${tableName} ADD time INTEGER DEFAULT 0`
|
||||||
);
|
);
|
||||||
|
} catch (e) {
|
||||||
|
e = e.toString();
|
||||||
|
if (e.indexOf('duplicate column name') === -1) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, `PRAGMA table_info(${dbVars.userPrefix}_avatar_history);`);
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,14 @@ import { useNotificationStore } from './notification';
|
|||||||
import { useAdvancedSettingsStore } from './settings/advanced';
|
import { useAdvancedSettingsStore } from './settings/advanced';
|
||||||
import { useUpdateLoopStore } from './updateLoop';
|
import { useUpdateLoopStore } from './updateLoop';
|
||||||
import { useUserStore } from './user';
|
import { useUserStore } from './user';
|
||||||
|
import { useVrcxStore } from './vrcx';
|
||||||
|
|
||||||
export const useAuthStore = defineStore('Auth', () => {
|
export const useAuthStore = defineStore('Auth', () => {
|
||||||
const advancedSettingsStore = useAdvancedSettingsStore();
|
const advancedSettingsStore = useAdvancedSettingsStore();
|
||||||
const notificationStore = useNotificationStore();
|
const notificationStore = useNotificationStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const updateLoopStore = useUpdateLoopStore();
|
const updateLoopStore = useUpdateLoopStore();
|
||||||
|
const vrcxStore = useVrcxStore();
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
@@ -138,6 +140,13 @@ export const useAuthStore = defineStore('Auth', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const attemptingAutoLogin = computed({
|
||||||
|
get: () => state.attemptingAutoLogin,
|
||||||
|
set: (value) => {
|
||||||
|
state.attemptingAutoLogin = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => watchState.isLoggedIn, () => userStore.currentUser],
|
[() => watchState.isLoggedIn, () => userStore.currentUser],
|
||||||
([isLoggedIn, currentUser]) => {
|
([isLoggedIn, currentUser]) => {
|
||||||
@@ -859,6 +868,7 @@ 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 {
|
||||||
@@ -869,6 +879,7 @@ export const useAuthStore = defineStore('Auth', () => {
|
|||||||
twoFactorAuthDialogVisible,
|
twoFactorAuthDialogVisible,
|
||||||
cachedConfig,
|
cachedConfig,
|
||||||
enableCustomEndpoint,
|
enableCustomEndpoint,
|
||||||
|
attemptingAutoLogin,
|
||||||
|
|
||||||
clearCookiesTryLogin,
|
clearCookiesTryLogin,
|
||||||
resendEmail2fa,
|
resendEmail2fa,
|
||||||
|
|||||||
+3
-2
@@ -95,7 +95,6 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
'VRCX_databaseVersion',
|
'VRCX_databaseVersion',
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
updateDatabaseVersion();
|
|
||||||
|
|
||||||
state.clearVRCXCacheFrequency = await configRepository.getInt(
|
state.clearVRCXCacheFrequency = await configRepository.getInt(
|
||||||
'VRCX_clearVRCXCacheFrequency',
|
'VRCX_clearVRCXCacheFrequency',
|
||||||
@@ -233,6 +232,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function updateDatabaseVersion() {
|
async function updateDatabaseVersion() {
|
||||||
|
// requires dbVars.userPrefix to be already set
|
||||||
const databaseVersion = 12;
|
const databaseVersion = 12;
|
||||||
let msgBox;
|
let msgBox;
|
||||||
if (state.databaseVersion < databaseVersion) {
|
if (state.databaseVersion < databaseVersion) {
|
||||||
@@ -768,6 +768,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
processScreenshot,
|
processScreenshot,
|
||||||
ipcEvent,
|
ipcEvent,
|
||||||
dragEnterCef,
|
dragEnterCef,
|
||||||
backupVrcRegistry
|
backupVrcRegistry,
|
||||||
|
updateDatabaseVersion
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user