IndexedDB migration: set USE_DEXIE_DB to false, remove unused functions, add raw display of data
This commit is contained in:
@@ -28,7 +28,6 @@ import { Settings, MASTER_SETTINGS_KEY } from "../db/tables/settings";
|
||||
import { Account } from "../db/tables/accounts";
|
||||
import { logger } from "../utils/logger";
|
||||
import { parseJsonField } from "../db/databaseUtil";
|
||||
import { USE_DEXIE_DB } from "../constants/app";
|
||||
import { importFromMnemonic } from "../libs/util";
|
||||
|
||||
/**
|
||||
@@ -133,10 +132,6 @@ export interface MigrationResult {
|
||||
* ```
|
||||
*/
|
||||
export async function getDexieContacts(): Promise<Contact[]> {
|
||||
if (!USE_DEXIE_DB) {
|
||||
throw new Error("Dexie database is not enabled");
|
||||
}
|
||||
|
||||
try {
|
||||
await db.open();
|
||||
const contacts = await db.contacts.toArray();
|
||||
@@ -215,8 +210,8 @@ export async function getSqliteContacts(): Promise<Contact[]> {
|
||||
* Retrieves all settings from the Dexie (IndexedDB) database
|
||||
*
|
||||
* This function connects to the Dexie database and retrieves all settings
|
||||
* records. It requires that USE_DEXIE_DB is enabled in the app constants.
|
||||
*
|
||||
* records.
|
||||
*
|
||||
* Settings include both master settings (id=1) and account-specific settings
|
||||
* that override the master settings for particular user accounts.
|
||||
*
|
||||
@@ -235,10 +230,6 @@ export async function getSqliteContacts(): Promise<Contact[]> {
|
||||
* ```
|
||||
*/
|
||||
export async function getDexieSettings(): Promise<Settings[]> {
|
||||
if (!USE_DEXIE_DB) {
|
||||
throw new Error("Dexie database is not enabled");
|
||||
}
|
||||
|
||||
try {
|
||||
await db.open();
|
||||
const settings = await db.settings.toArray();
|
||||
@@ -388,7 +379,7 @@ export async function getSqliteAccounts(): Promise<Account[]> {
|
||||
* Retrieves all accounts from the Dexie (IndexedDB) database
|
||||
*
|
||||
* This function connects to the Dexie database and retrieves all account
|
||||
* records. It requires that USE_DEXIE_DB is enabled in the app constants.
|
||||
* records.
|
||||
*
|
||||
* The function handles database opening and error conditions, providing
|
||||
* detailed logging for debugging purposes.
|
||||
@@ -408,10 +399,6 @@ export async function getSqliteAccounts(): Promise<Account[]> {
|
||||
* ```
|
||||
*/
|
||||
export async function getDexieAccounts(): Promise<Account[]> {
|
||||
if (!USE_DEXIE_DB) {
|
||||
throw new Error("Dexie database is not enabled");
|
||||
}
|
||||
|
||||
try {
|
||||
const accountsDB = await accountsDBPromise;
|
||||
await accountsDB.open();
|
||||
@@ -1799,60 +1786,3 @@ export async function migrateAll(
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test function to verify migration of specific settings fields
|
||||
*
|
||||
* This function tests the migration of the specific fields you mentioned:
|
||||
* firstName, isRegistered, profileImageUrl, showShortcutBvc, and searchBoxes
|
||||
*
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
export async function testSettingsMigration(): Promise<void> {
|
||||
logger.info("[MigrationService] Starting settings migration test");
|
||||
|
||||
try {
|
||||
// First, compare databases to see current state
|
||||
const comparison = await compareDatabases();
|
||||
logger.info("[MigrationService] Pre-migration comparison:", {
|
||||
dexieSettings: comparison.dexieSettings.length,
|
||||
sqliteSettings: comparison.sqliteSettings.length,
|
||||
dexieAccounts: comparison.dexieAccounts.length,
|
||||
sqliteAccounts: comparison.sqliteAccounts.length
|
||||
});
|
||||
|
||||
// Run settings migration
|
||||
const settingsResult = await migrateSettings(true);
|
||||
logger.info("[MigrationService] Settings migration result:", settingsResult);
|
||||
|
||||
// Run accounts migration
|
||||
const accountsResult = await migrateAccounts(true);
|
||||
logger.info("[MigrationService] Accounts migration result:", accountsResult);
|
||||
|
||||
// Compare databases again to see changes
|
||||
const postComparison = await compareDatabases();
|
||||
logger.info("[MigrationService] Post-migration comparison:", {
|
||||
dexieSettings: postComparison.dexieSettings.length,
|
||||
sqliteSettings: postComparison.sqliteSettings.length,
|
||||
dexieAccounts: postComparison.dexieAccounts.length,
|
||||
sqliteAccounts: postComparison.sqliteAccounts.length
|
||||
});
|
||||
|
||||
// Check if the specific fields were migrated
|
||||
if (postComparison.sqliteSettings.length > 0) {
|
||||
const sqliteSettings = postComparison.sqliteSettings[0];
|
||||
logger.info("[MigrationService] Migrated settings fields:", {
|
||||
firstName: sqliteSettings.firstName,
|
||||
isRegistered: sqliteSettings.isRegistered,
|
||||
profileImageUrl: sqliteSettings.profileImageUrl,
|
||||
showShortcutBvc: sqliteSettings.showShortcutBvc,
|
||||
searchBoxes: sqliteSettings.searchBoxes
|
||||
});
|
||||
}
|
||||
|
||||
logger.info("[MigrationService] Migration test completed successfully");
|
||||
} catch (error) {
|
||||
logger.error("[MigrationService] Migration test failed:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user