Browse Source

chore: a couple missed files

pull/188/head
Matthew Raymer 5 days ago
parent
commit
eb77547ba1
  1. 43
      src/services/migrationService.ts

43
src/services/migrationService.ts

@ -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'",
);
migrationLog(
`🔍 [Migration] Table check result: ${JSON.stringify(tableCheck)}`,
);
const rowCount = await sqlQuery("SELECT COUNT(*) as count FROM active_identity"); const rowCount = await sqlQuery(
migrationLog(`🔍 [Migration] Row count in active_identity: ${JSON.stringify(rowCount)}`); "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)}`,
);
} }
} }

Loading…
Cancel
Save