forked from jsnbuchanan/crowd-funder-for-time-pwa
chore: a couple missed files
This commit is contained in:
@@ -521,9 +521,18 @@ export async function runMigrations<T>(
|
|||||||
// Update any old migration names to new ones
|
// Update any old migration names to new ones
|
||||||
for (const [oldName, newName] of migrationNameMap) {
|
for (const [oldName, newName] of migrationNameMap) {
|
||||||
try {
|
try {
|
||||||
await sqlExec("UPDATE migrations SET name = ? WHERE name = ?", [newName, oldName]);
|
await sqlExec("UPDATE migrations SET name = ? WHERE name = ?", [
|
||||||
if (await sqlQuery("SELECT 1 FROM migrations WHERE name = ? LIMIT 1", [newName])) {
|
newName,
|
||||||
migrationLog(`🔄 [Migration] Renamed migration: ${oldName} → ${newName}`);
|
oldName,
|
||||||
|
]);
|
||||||
|
if (
|
||||||
|
await sqlQuery("SELECT 1 FROM migrations WHERE name = ? LIMIT 1", [
|
||||||
|
newName,
|
||||||
|
])
|
||||||
|
) {
|
||||||
|
migrationLog(
|
||||||
|
`🔄 [Migration] Renamed migration: ${oldName} → ${newName}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Ignore errors - migration might not exist
|
// Ignore errors - migration might not exist
|
||||||
@@ -594,21 +603,35 @@ export async function runMigrations<T>(
|
|||||||
migrationLog(`🔧 [Migration] Executing SQL for: ${migration.name}`);
|
migrationLog(`🔧 [Migration] Executing SQL for: ${migration.name}`);
|
||||||
migrationLog(`🔧 [Migration] SQL content: ${migration.sql}`);
|
migrationLog(`🔧 [Migration] SQL content: ${migration.sql}`);
|
||||||
const execResult = await sqlExec(migration.sql);
|
const execResult = await sqlExec(migration.sql);
|
||||||
migrationLog(`🔧 [Migration] SQL execution result: ${JSON.stringify(execResult)}`);
|
migrationLog(
|
||||||
|
`🔧 [Migration] SQL execution result: ${JSON.stringify(execResult)}`,
|
||||||
|
);
|
||||||
|
|
||||||
// Debug: Check if active_identity table exists and has data
|
// Debug: Check if active_identity table exists and has data
|
||||||
if (migration.name === "003_active_identity_and_seed_backup") {
|
if (migration.name === "003_active_identity_and_seed_backup") {
|
||||||
try {
|
try {
|
||||||
const tableCheck = await sqlQuery("SELECT name FROM sqlite_master WHERE type='table' AND name='active_identity'");
|
const tableCheck = await sqlQuery(
|
||||||
migrationLog(`🔍 [Migration] Table check result: ${JSON.stringify(tableCheck)}`);
|
"SELECT name FROM sqlite_master WHERE type='table' AND name='active_identity'",
|
||||||
|
);
|
||||||
const rowCount = await sqlQuery("SELECT COUNT(*) as count FROM active_identity");
|
migrationLog(
|
||||||
migrationLog(`🔍 [Migration] Row count in active_identity: ${JSON.stringify(rowCount)}`);
|
`🔍 [Migration] Table check result: ${JSON.stringify(tableCheck)}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
const rowCount = await sqlQuery(
|
||||||
|
"SELECT COUNT(*) as count FROM active_identity",
|
||||||
|
);
|
||||||
|
migrationLog(
|
||||||
|
`🔍 [Migration] Row count in active_identity: ${JSON.stringify(rowCount)}`,
|
||||||
|
);
|
||||||
|
|
||||||
const allRows = await sqlQuery("SELECT * FROM active_identity");
|
const allRows = await sqlQuery("SELECT * FROM active_identity");
|
||||||
migrationLog(`🔍 [Migration] All rows in active_identity: ${JSON.stringify(allRows)}`);
|
migrationLog(
|
||||||
|
`🔍 [Migration] All rows in active_identity: ${JSON.stringify(allRows)}`,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
migrationLog(`❌ [Migration] Debug query failed: ${JSON.stringify(error)}`);
|
migrationLog(
|
||||||
|
`❌ [Migration] Debug query failed: ${JSON.stringify(error)}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -673,25 +673,25 @@ export const PlatformServiceMixin = {
|
|||||||
logger.debug(
|
logger.debug(
|
||||||
"[PlatformServiceMixin] Active identity is null (initial state), attempting auto-selection",
|
"[PlatformServiceMixin] Active identity is null (initial state), attempting auto-selection",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Try to auto-select first available account
|
// Try to auto-select first available account
|
||||||
const availableAccounts = await this.$dbQuery(
|
const availableAccounts = await this.$dbQuery(
|
||||||
"SELECT did FROM accounts ORDER BY dateCreated, did LIMIT 1",
|
"SELECT did FROM accounts ORDER BY dateCreated, did LIMIT 1",
|
||||||
);
|
);
|
||||||
|
|
||||||
if (availableAccounts?.values?.length) {
|
if (availableAccounts?.values?.length) {
|
||||||
const firstAccountDid = availableAccounts.values[0][0] as string;
|
const firstAccountDid = availableAccounts.values[0][0] as string;
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"[PlatformServiceMixin] Auto-selecting first account as active:",
|
"[PlatformServiceMixin] Auto-selecting first account as active:",
|
||||||
{ firstAccountDid },
|
{ firstAccountDid },
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update active_identity table with the first account
|
// Update active_identity table with the first account
|
||||||
await this.$dbExec(
|
await this.$dbExec(
|
||||||
"UPDATE active_identity SET activeDid = ?, lastUpdated = datetime('now') WHERE id = 1",
|
"UPDATE active_identity SET activeDid = ?, lastUpdated = datetime('now') WHERE id = 1",
|
||||||
[firstAccountDid],
|
[firstAccountDid],
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"[PlatformServiceMixin] Active identity auto-selected successfully",
|
"[PlatformServiceMixin] Active identity auto-selected successfully",
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user