WIP: restore database migration system and improve error handling

- Restore runMigrations functionality for database schema migrations
- Remove indexedDBMigrationService.ts (was for IndexedDB to SQLite migration)
- Recreate migrationService.ts and db-sql/migration.ts for schema management
- Add proper TypeScript error handling with type guards in AccountViewView
- Fix CreateAndSubmitClaimResult property access in QuickActionBvcBeginView
- Remove LeafletMouseEvent from Vue components array (it's a type, not component)
- Add null check for UserNameDialog callback to prevent undefined assignment
- Implement extractErrorMessage helper function for consistent error handling
- Update router to remove database-migration route

The migration system now properly handles database schema evolution
across app versions, while the IndexedDB to SQLite migration service
has been removed as it was specific to that one-time migration.
This commit is contained in:
Matthew Raymer
2025-06-23 08:25:10 +00:00
parent 3baa6633a6
commit daed0a97c9
70 changed files with 185 additions and 3986 deletions

View File

@@ -363,19 +363,8 @@ import GiftedDialog from "../components/GiftedDialog.vue";
import OfferDialog from "../components/OfferDialog.vue";
import ContactNameDialog from "../components/ContactNameDialog.vue";
import TopMessage from "../components/TopMessage.vue";
import {
APP_SERVER,
AppString,
NotificationIface,
USE_DEXIE_DB,
} from "../constants/app";
import {
db,
logConsoleAndDb,
retrieveSettingsForActiveAccount,
updateAccountSettings,
updateDefaultSettings,
} from "../db/index";
import { APP_SERVER, AppString, NotificationIface } from "../constants/app";
import { logConsoleAndDb } from "../db/index";
import { Contact } from "../db/tables/contacts";
import * as databaseUtil from "../db/databaseUtil";
import { getContactJwtFromJwtUrl } from "../libs/crypto";
@@ -384,7 +373,6 @@ import {
CONTACT_CSV_HEADER,
createEndorserJwtForDid,
errorStringForLog,
GiveSummaryRecord,
getHeaders,
isDid,
register,
@@ -448,11 +436,7 @@ export default class ContactsView extends Vue {
libsUtil = libsUtil;
public async created() {
let settings = await databaseUtil.retrieveSettingsForActiveAccount();
if (USE_DEXIE_DB) {
await db.open();
settings = await retrieveSettingsForActiveAccount();
}
const settings = await databaseUtil.retrieveSettingsForActiveAccount();
this.activeDid = settings.activeDid || "";
this.apiServer = settings.apiServer || "";
this.isRegistered = !!settings.isRegistered;
@@ -477,15 +461,6 @@ export default class ContactsView extends Vue {
this.contacts = databaseUtil.mapQueryResultToValues(
dbAllContacts,
) as unknown as Contact[];
if (USE_DEXIE_DB) {
await db.open();
// .orderBy("name") wouldn't retrieve any entries with a blank name
// .toCollection.sortBy("name") didn't sort in an order I understood
const baseContacts = await db.contacts.toArray();
this.contacts = baseContacts.sort((a, b) =>
(a.name || "").localeCompare(b.name || ""),
);
}
}
private async processContactJwt() {
@@ -545,9 +520,6 @@ export default class ContactsView extends Vue {
await databaseUtil.updateDidSpecificSettings(this.activeDid, {
isRegistered: true,
});
if (USE_DEXIE_DB) {
await updateAccountSettings(this.activeDid, { isRegistered: true });
}
this.isRegistered = true;
this.$notify(
{
@@ -855,15 +827,7 @@ export default class ContactsView extends Vue {
this.contacts = databaseUtil.mapQueryResultToValues(
dbAllContacts,
) as unknown as Contact[];
if (USE_DEXIE_DB) {
await db.open();
// .orderBy("name") wouldn't retrieve any entries with a blank name
// .toCollection.sortBy("name") didn't sort in an order I understood
const baseContacts = await db.contacts.toArray();
this.contacts = baseContacts.sort((a, b) =>
(a.name || "").localeCompare(b.name || ""),
);
}
return;
}
@@ -942,9 +906,6 @@ export default class ContactsView extends Vue {
"contacts",
);
await platformService.dbExec(sql, params);
if (USE_DEXIE_DB) {
await db.contacts.add(newContact);
}
}
private async addContact(newContact: Contact) {
@@ -962,11 +923,8 @@ export default class ContactsView extends Vue {
newContact as unknown as Record<string, unknown>,
"contacts",
);
let contactPromise = platformService.dbExec(sql, params);
if (USE_DEXIE_DB) {
// @ts-expect-error since the result of this promise won't be used, and this will go away soon
contactPromise = db.contacts.add(newContact);
}
const contactPromise = platformService.dbExec(sql, params);
return contactPromise
.then(() => {
const allContacts = this.contacts.concat([newContact]);
@@ -998,11 +956,7 @@ export default class ContactsView extends Vue {
await databaseUtil.updateDefaultSettings({
hideRegisterPromptOnNewContact: stopAsking,
});
if (USE_DEXIE_DB) {
await updateDefaultSettings({
hideRegisterPromptOnNewContact: stopAsking,
});
}
this.hideRegisterPromptOnNewContact = stopAsking;
}
},
@@ -1011,11 +965,7 @@ export default class ContactsView extends Vue {
await databaseUtil.updateDefaultSettings({
hideRegisterPromptOnNewContact: stopAsking,
});
if (USE_DEXIE_DB) {
await updateDefaultSettings({
hideRegisterPromptOnNewContact: stopAsking,
});
}
this.hideRegisterPromptOnNewContact = stopAsking;
}
},
@@ -1098,9 +1048,6 @@ export default class ContactsView extends Vue {
"UPDATE contacts SET registered = ? WHERE did = ?",
[true, contact.did],
);
if (USE_DEXIE_DB) {
await db.contacts.update(contact.did, { registered: true });
}
this.$notify(
{
@@ -1171,7 +1118,6 @@ export default class ContactsView extends Vue {
this.activeDid,
this.apiServer,
this.axios,
db,
contact,
visibility,
);
@@ -1311,11 +1257,6 @@ export default class ContactsView extends Vue {
await databaseUtil.updateDefaultSettings({
showContactGivesInline: newShowValue,
});
if (USE_DEXIE_DB) {
await updateDefaultSettings({
showContactGivesInline: newShowValue,
});
}
} catch (err) {
const fullError =
"Error updating contact-amounts setting: " + errorStringForLog(err);