Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update datamodel upgrade logic for browser extension to fix pragma conflicts

Leendert de Borst87c31fc3c7f3
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Upgrade.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Upgrade.tsx
index 9ad1895db..2d58febac 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Upgrade.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Upgrade.tsx
@@ -131,12 +131,14 @@ const Upgrade: React.FC = () => {
return;
}
- // Use the useVaultMutate hook to handle the upgrade and vault upload
+ /**
+ * Use the useVaultMutate hook to handle the upgrade and vault upload.
+ * IMPORTANT: Do NOT wrap migration SQL in beginTransaction/commitTransaction!
+ * The migration SQL contains PRAGMA foreign_keys statements that MUST be executed
+ * outside of any transaction to take effect. The SQL handles its own transactions.
+ */
await executeVaultMutationAsync(async () => {
- // Begin transaction
- sqliteClient.beginTransaction();
-
- // Execute each SQL command
+ // Execute each SQL command (each migration script handles its own transactions)
for (let i = 0; i < upgradeResult.sqlCommands.length; i++) {
const sqlCommand = upgradeResult.sqlCommands[i];
@@ -144,13 +146,9 @@ const Upgrade: React.FC = () => {
sqliteClient.executeRaw(sqlCommand);
} catch (error) {
console.error(`Error executing SQL command ${i + 1}:`, sqlCommand, error);
- sqliteClient.rollbackTransaction();
throw new Error(t('upgrade.alerts.failedToApplyMigration', { current: i + 1, total: upgradeResult.sqlCommands.length }));
}
}
-
- // Commit transaction
- sqliteClient.commitTransaction();
});
await handleUpgradeSuccess();