Skip to content

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

Add TOTP extra column support to browser extension (#2159)

Leendert de Borst64c501713bcb
diff --git a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
index 5266b2fc7..abdb0854e 100644
--- a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
+++ b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
-import * as OTPAuth from 'otpauth';
import { storage } from 'wxt/utils/storage';
import { AUTH_STORAGE_KEYS, dirtyScopeStorageKey, SESSION_STORAGE_KEYS, StorageKeys, vaultDataStorageKeys, VAULT_LOCK_STORAGE_KEYS } from '@/utils/constants/storageKeys';
@@ -15,12 +14,13 @@ import { readLegacySessionEncryptionKey } from '@/utils/legacy/LegacyStorageKeyF
import { requiresLegacyAccountKeyMigration } from '@/utils/legacy/LegacyStorageModelMigration';
import { LocalPreferencesService } from '@/utils/LocalPreferencesService';
import { getManifestRevisions, manifestsRequiringPull, toManifestRevisionMap } from '@/utils/ManifestRevisions';
-import { sendMessage } from '@/utils/messaging/ExtensionMessaging';
+import { sendMessage, type TotpSecret } from '@/utils/messaging/ExtensionMessaging';
import { RecentlySelectedItemService } from '@/utils/RecentlySelectedItemService';
import { filterItems, AutofillMatchingMode, extractRootDomain, isUrlAlreadyLinked, generatePassword, vaultCodecExtractBuckets, vaultCodecBucketLayout, vaultCodecOverflowTable } from '@/utils/RustCore';
import { ServiceDetectionUtility } from '@/utils/serviceDetection/ServiceDetectionUtility';
import { SqliteClient } from '@/utils/SqliteClient';
import { getStorageItem } from '@/utils/StorageUtility';
+import { generateTotpCode } from '@/utils/TotpUtility';
import { ApiAuthError } from '@/utils/types/errors/ApiAuthError';
import { ApiRequestError } from '@/utils/types/errors/ApiRequestError';
import { AppErrorCode, formatErrorWithCode } from '@/utils/types/errors/AppErrorCodes';
@@ -2154,7 +2154,7 @@ export async function handleSearchItemsWithTotp(
*/
export async function handleGetTotpSecrets(
message: { itemIds: string[] }
-): Promise<{ success: boolean; secrets?: Record<string, string>; error?: string }> {
+): Promise<{ success: boolean; secrets?: Record<string, TotpSecret>; error?: string }> {
const encryptionKey = await handleGetEncryptionKey();
if (!encryptionKey) {
@@ -2163,12 +2163,18 @@ export async function handleGetTotpSecrets(
try {
const sqliteClient = await createVaultSqliteClient();
- const secrets: Record<string, string> = {};
+ const secrets: Record<string, TotpSecret> = {};
for (const itemId of message.itemIds) {
const totpCodes = sqliteClient.items.getTotpCodesForItem(itemId);
if (totpCodes.length > 0) {
- secrets[itemId] = totpCodes[0].SecretKey;
+ const totpCode = totpCodes[0];
+ secrets[itemId] = {
+ SecretKey: totpCode.SecretKey,
+ Algorithm: totpCode.Algorithm,
+ Digits: totpCode.Digits,
+ Period: totpCode.Period
+ };
}
}
@@ -2202,14 +2208,12 @@ export async function handleGenerateTotpCode(
return { success: false, error: 'No TOTP codes found for this item' };
}
- const totp = new OTPAuth.TOTP({
- secret: totpCodes[0].SecretKey,
- algorithm: 'SHA1',
- digits: 6,
- period: 30
- });
+ const code = generateTotpCode(totpCodes[0].SecretKey, totpCodes[0]);
+ if (!code) {
+ return { success: false, error: formatErrorWithCode(await t('common.errors.unknownError'), AppErrorCode.ITEM_READ_FAILED) };
+ }
- return { success: true, code: totp.generate() };
+ return { success: true, code };
} catch (error) {
console.error('Error generating TOTP code:', error);
return { success: false, error: formatErrorWithCode(await t('common.errors.unknownError'), AppErrorCode.ITEM_READ_FAILED) };
diff --git a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts b/apps/browser-extension/src/entrypoints/contentScript/Popup.ts
index b034633cc..e2afa29e5 100644
--- a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts
+++ b/apps/browser-extension/src/entrypoints/contentScript/Popup.ts
@@ -1,15 +1,14 @@
-import * as OTPAuth from 'otpauth';
-
import { fillItem, fillTotpCode } from '@/entrypoints/contentScript/Form';
import { ItemTypeIconSvgs } from '@/utils/dist/core/models/icons';
import type { Item } from '@/utils/dist/core/models/vault';
-import { FieldKey, getFieldValue } from '@/utils/dist/core/models/vault';
+import { FieldKey, getFieldValue, normalizeTotpPeriod } from '@/utils/dist/core/models/vault';
import { LocalPreferencesService } from '@/utils/LocalPreferencesService';
-import { sendMessage } from '@/utils/messaging/ExtensionMessaging';
+import { sendMessage, type TotpSecret } from '@/utils/messaging/ExtensionMessaging';
import { ClickValidator } from '@/utils/security/ClickValidator';
import { ServiceDetectionUtility } from '@/utils/serviceDetection/ServiceDetectionUtility';
import { SqliteClient } from '@/utils/SqliteClient';
+import { generateTotpCode, getTotpRemainingSeconds } from '@/utils/TotpUtility';
import { t } from '@/i18n/StandaloneI18n';
@@ -85,29 +84,15 @@ function cleanupTotpInterval(): void {
}
/**
- * Generate TOTP code from secret key
+ * Generate a TOTP code from a secret and its stored parameters, formatted with a space in the middle.
*/
-function generateTotpCode(secretKey: string): string {
- try {
- const totp = new OTPAuth.TOTP({
- secret: secretKey,
- algorithm: 'SHA1',
- digits: 6,
- period: 30
- });
- const code = totp.generate();
- // Format as "XXX XXX" with space in middle
- return `${code.slice(0, 3)} ${code.slice(3)}`;
- } catch {
+function formatTotpCodeForSecret(secret: TotpSecret): string {
+ const code = generateTotpCode(secret.SecretKey, secret);
+ if (!code) {
return '--- ---';
}
-}
-
-/**
- * Get remaining seconds until next TOTP code
- */
-function getTotpRemainingSeconds(): number {
- return 30 - (Math.floor(Date.now() / 1000) % 30);
+ const half = code.length % 2 === 0 ? code.length / 2 : 3;
+ return `${code.slice(0, half)} ${code.slice(half)}`;
}
/**
@@ -520,17 +505,15 @@ function createPieSlicePath(cx: number, cy: number, r: number, fraction: number)
*/
function updateTotpCodes(
codeElements: Map<string, { codeSpan: HTMLSpanElement; pieChart: SVGPathElement }>,
- secrets: Record<string, string>
+ secrets: Record<string, TotpSecret>
): void {
- const remainingSeconds = getTotpRemainingSeconds();
- const fraction = remainingSeconds / 30;
-
codeElements.forEach((elements, itemId) => {
const secret = secrets[itemId];
if (secret) {
- elements.codeSpan.textContent = generateTotpCode(secret);
+ elements.codeSpan.textContent = formatTotpCodeForSecret(secret);
}
- elements.pieChart.setAttribute('d', createPieSlicePath(6, 6, 5, fraction));
+ // Each code counts down over its own period, so the pie is computed per item rather than once.
+ elements.pieChart.setAttribute('d', createPieSlicePath(6, 6, 5, getTotpRemainingSeconds(secret) / normalizeTotpPeriod(secret?.Period)));
});
}
@@ -541,7 +524,7 @@ function updateTotpCodes(
*/
function createTotpItem(
item: Item,
- secret: string | undefined,
+ secret: TotpSecret | undefined,
input: HTMLInputElement,
rootContainer: HTMLElement,
codeElements?: Map<string, { codeSpan: HTMLSpanElement; pieChart: SVGPathElement }>,
@@ -588,11 +571,10 @@ function createTotpItem(
// TOTP code span - show generated code or static placeholder
const codeSpan = document.createElement('span');
- codeSpan.textContent = secret ? generateTotpCode(secret) : '000 000';
+ codeSpan.textContent = secret ? formatTotpCodeForSecret(secret) : '000 000';
// Pie chart countdown - blue pie that shrinks clockwise from top
- const remainingSeconds = getTotpRemainingSeconds();
- const fraction = secret ? remainingSeconds / 30 : 1; // Static shows full pie
+ const fraction = secret ? getTotpRemainingSeconds(secret) / normalizeTotpPeriod(secret.Period) : 1; // Static shows full pie
const svgNS = 'http://www.w3.org/2000/svg';
const svg = document.createElementNS(svgNS, 'svg');
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpBlock.tsx b/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpBlock.tsx
index 9ebcbfff4..18c3429b0 100644
--- a/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpBlock.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpBlock.tsx
@@ -1,4 +1,3 @@
-import * as OTPAuth from 'otpauth';
import React, { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
@@ -6,16 +5,18 @@ import { useDb } from '@/entrypoints/popup/context/DbContext';
import type { TotpCode } from '@/utils/dist/core/models/vault';
import { sendMessage } from '@/utils/messaging/ExtensionMessaging';
+import { generateTotpCode, getTotpElapsedPercentage, getTotpRemainingSeconds } from '@/utils/TotpUtility';
/**
- * Formats a TOTP code as "XXX XXX" with a space in the middle for better readability.
+ * Formats a TOTP code with a space in the middle for better readability, e.g. "XXX XXX" or "XXXX XXXX".
*/
const formatTotpCode = (code: string | undefined): string => {
if (!code) {
return '';
}
- if (code.length === 6) {
- return `${code.slice(0, 3)} ${code.slice(3)}`;
+ if (code.length % 2 === 0) {
+ const half = code.length / 2;
+ return `${code.slice(0, half)} ${code.slice(half)}`;
}
return code;
};
@@ -35,46 +36,6 @@ const TotpBlock: React.FC<TotpBlockProps> = ({ itemId }) => {
const [copiedId, setCopiedId] = useState<string | null>(null);
const dbContext = useDb();
- /**
- * Gets the remaining seconds for the TOTP code.
- */
- const getRemainingSeconds = (step = 30): number => {
- const totp = new OTPAuth.TOTP({
- secret: 'dummy', // We only need this for timing calculations
- algorithm: 'SHA1',
- digits: 6,
- period: step
- });
- return totp.period - (Math.floor(Date.now() / 1000) % totp.period);
- };
-
- /**
- * Gets the remaining percentage for the TOTP code.
- */
- const getRemainingPercentage = (): number => {
- const remaining = getRemainingSeconds();
- // Invert the percentage so it counts down instead of up
- return Math.floor(((30.0 - remaining) / 30.0) * 100);
- };
-
- /**
- * Generates a TOTP code for a given secret key.
- */
- const generateTotpCode = (secretKey: string): string => {
- try {
- const totp = new OTPAuth.TOTP({
- secret: secretKey,
- algorithm: 'SHA1',
- digits: 6,
- period: 30
- });
- return totp.generate();
- } catch (error) {
- console.error('Error generating TOTP code:', error);
- return 'Error';
- }
- };
-
/**
* Copies a TOTP code to the clipboard.
*/
@@ -132,14 +93,8 @@ const TotpBlock: React.FC<TotpBlockProps> = ({ itemId }) => {
const updateTotpCodes = (prevCodes: Record<string, string>): Record<string, string> => {
const newCodes: Record<string, string> = {};
totpCodes.forEach(code => {
- const generatedCode = generateTotpCode(code.SecretKey);
- // Only update if we have a valid code
- if (generatedCode !== 'Error') {
- newCodes[code.Id] = generatedCode;
- } else {
- // Keep the previous code if there's an error
- newCodes[code.Id] = prevCodes[code.Id] ?? 'Error';
- }
+ // Keep the previous code when generation fails, so a single bad tick doesn't blank the display.
+ newCodes[code.Id] = generateTotpCode(code.SecretKey, code) ?? prevCodes[code.Id] ?? 'Error';
});
return newCodes;
};
@@ -147,7 +102,7 @@ const TotpBlock: React.FC<TotpBlockProps> = ({ itemId }) => {
// Generate initial codes
const initialCodes: Record<string, string> = {};
totpCodes.forEach(code => {
- initialCodes[code.Id] = generateTotpCode(code.SecretKey);
+ initialCodes[code.Id] = generateTotpCode(code.SecretKey, code) ?? 'Error';
});
setCurrentCodes(initialCodes);
@@ -200,14 +155,14 @@ const TotpBlock: React.FC<TotpBlockProps> = ({ itemId }) => {
{copiedId === totpCode.Id ? (
<span className="text-green-600 dark:text-green-400">{t('common.copied')}</span>
) : (
- <span className="text-gray-500 dark:text-gray-400">{getRemainingSeconds()}s</span>
+ <span className="text-gray-500 dark:text-gray-400">{getTotpRemainingSeconds(totpCode)}s</span>
)}
</div>
</div>
<div className="w-1 h-6 bg-gray-200 rounded-full dark:bg-gray-600">
<div
className="bg-blue-600 rounded-full transition-all"
- style={{ height: `${getRemainingPercentage()}%`, width: '100%' }}
+ style={{ height: `${getTotpElapsedPercentage(totpCode)}%`, width: '100%' }}
/>
</div>
</div>
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpEditor.tsx b/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpEditor.tsx
index 2c9848231..b5e43cc89 100644
--- a/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpEditor.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpEditor.tsx
@@ -7,6 +7,8 @@ import ConfirmDeleteModal from '@/entrypoints/popup/components/Dialogs/ConfirmDe
import ModalWrapper from '@/entrypoints/popup/components/Dialogs/ModalWrapper';
import type { TotpCode } from '@/utils/dist/core/models/vault';
+import { normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD } from '@/utils/dist/core/models/vault';
+import { buildOtpAuthUri } from '@/utils/TotpUtility';
type TotpFormData = {
name: string;
@@ -58,9 +60,12 @@ const TotpEditor: React.FC<TotpEditorProps> = ({
/**
* Sanitizes the secret key by extracting it from a TOTP URI if needed
*/
- const sanitizeSecretKey = (secretKeyInput: string, nameInput: string): { secretKey: string, name: string } => {
+ const sanitizeSecretKey = (secretKeyInput: string, nameInput: string): { secretKey: string, name: string, algorithm: string, digits: number, period: number } => {
let secretKey = secretKeyInput.trim();
let name = nameInput.trim();
+ let algorithm = TOTP_DEFAULT_ALGORITHM;
+ let digits = TOTP_DEFAULT_DIGITS;
+ let period = TOTP_DEFAULT_PERIOD;
// Check if it's a TOTP URI
if (secretKey.toLowerCase().startsWith('otpauth://totp/')) {
@@ -68,6 +73,10 @@ const TotpEditor: React.FC<TotpEditorProps> = ({
const uri = OTPAuth.URI.parse(secretKey);
if (uri instanceof OTPAuth.TOTP) {
secretKey = uri.secret.base32;
+ // Keep the URI's parameters instead of silently regenerating codes with the defaults.
+ algorithm = normalizeTotpAlgorithm(uri.algorithm);
+ digits = normalizeTotpDigits(uri.digits);
+ period = normalizeTotpPeriod(uri.period);
// If name is empty, use the label from the URI
if (!name && uri.label) {
name = uri.label;
@@ -87,7 +96,7 @@ const TotpEditor: React.FC<TotpEditorProps> = ({
}
// Name is optional; keep it blank when none was provided or derived.
- return { secretKey, name };
+ return { secretKey, name, algorithm, digits, period };
};
/**
@@ -147,13 +156,16 @@ const TotpEditor: React.FC<TotpEditorProps> = ({
try {
// Sanitize the secret key
- const { secretKey, name } = sanitizeSecretKey(formData.secretKey, formData.name);
+ const { secretKey, name, algorithm, digits, period } = sanitizeSecretKey(formData.secretKey, formData.name);
// Create new TOTP code
const newTotpCode: TotpCode = {
Id: crypto.randomUUID().toUpperCase(),
Name: name,
SecretKey: secretKey,
+ Algorithm: algorithm,
+ Digits: digits,
+ Period: period,
ItemId: '' // Will be set when saving the item
};
@@ -285,7 +297,7 @@ const TotpEditor: React.FC<TotpEditorProps> = ({
const issuer = itemDisplayName || 'AliasVault';
const accountName = itemUsername || editingTotpCode.Name;
const label = `${encodeURIComponent(issuer)}:${encodeURIComponent(accountName)}`;
- const totpUri = `otpauth://totp/${label}?secret=${editingTotpCode.SecretKey}&issuer=${encodeURIComponent(issuer)}`;
+ const totpUri = buildOtpAuthUri(label, editingTotpCode.SecretKey, issuer, editingTotpCode);
QRCode.toDataURL(totpUri, {
width: 256,
diff --git a/apps/browser-extension/src/utils/TotpUtility.ts b/apps/browser-extension/src/utils/TotpUtility.ts
new file mode 100644
index 000000000..2a1daf730
--- /dev/null
+++ b/apps/browser-extension/src/utils/TotpUtility.ts
@@ -0,0 +1,98 @@
+import * as OTPAuth from 'otpauth';
+
+import { normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD } from '@/utils/dist/core/models/vault';
+
+/**
+ * The RFC 6238 parameters a TOTP code was created with, as stored on the vault row.
+ */
+export type TotpParameters = {
+ /** HMAC algorithm: "SHA1", "SHA256" or "SHA512". */
+ Algorithm?: string;
+ /** Number of digits in the generated code. */
+ Digits?: number;
+ /** Time step in seconds. */
+ Period?: number;
+};
+
+/**
+ * Build an OTPAuth.TOTP for a secret using the stored parameters, falling back to the RFC 6238
+ * defaults for anything missing or unsupported.
+ *
+ * @param secretKey - Base32-encoded TOTP secret
+ * @param parameters - Stored algorithm/digits/period
+ * @returns A configured OTPAuth.TOTP instance
+ */
+function createTotp(secretKey: string, parameters?: TotpParameters): OTPAuth.TOTP {
+ return new OTPAuth.TOTP({
+ secret: secretKey,
+ algorithm: normalizeTotpAlgorithm(parameters?.Algorithm),
+ digits: normalizeTotpDigits(parameters?.Digits),
+ period: normalizeTotpPeriod(parameters?.Period)
+ });
+}
+
+/**
+ * Generate the current TOTP code for a secret using its stored parameters.
+ *
+ * @param secretKey - Base32-encoded TOTP secret
+ * @param parameters - Stored algorithm/digits/period
+ * @returns The current code, or null when the secret cannot be used
+ */
+export function generateTotpCode(secretKey: string, parameters?: TotpParameters): string | null {
+ try {
+ return createTotp(secretKey, parameters).generate();
+ } catch (error) {
+ console.error('Error generating TOTP code:', error);
+ return null;
+ }
+}
+
+/**
+ * Seconds remaining in the current time step of a TOTP code.
+ *
+ * @param parameters - Stored algorithm/digits/period; only the period matters here
+ * @returns Seconds until the code rolls over
+ */
+export function getTotpRemainingSeconds(parameters?: TotpParameters): number {
+ const period = normalizeTotpPeriod(parameters?.Period);
+ return period - (Math.floor(Date.now() / 1000) % period);
+}
+
+/**
+ * How far the current time step has progressed, as a percentage. Used to drive the countdown ring.
+ *
+ * @param parameters - Stored algorithm/digits/period; only the period matters here
+ * @returns A value between 0 and 100
+ */
+export function getTotpElapsedPercentage(parameters?: TotpParameters): number {
+ const period = normalizeTotpPeriod(parameters?.Period);
+ return Math.floor(((period - getTotpRemainingSeconds(parameters)) / period) * 100);
+}
+
+/**
+ * Serialize a TOTP code back to an `otpauth://` URI. Non-default parameters are written out so a
+ * scanned QR reproduces the same codes.
+ *
+ * @param label - URL-encoded label, typically "Issuer:account"
+ * @param secretKey - Base32 secret
+ * @param issuer - Issuer name
+ * @param parameters - Stored algorithm/digits/period
+ * @returns The otpauth:// URI
+ */
+export function buildOtpAuthUri(label: string, secretKey: string, issuer: string, parameters?: TotpParameters): string {
+ const algorithm = normalizeTotpAlgorithm(parameters?.Algorithm);
+ const digits = normalizeTotpDigits(parameters?.Digits);
+ const period = normalizeTotpPeriod(parameters?.Period);
+
+ let uri = `otpauth://totp/${label}?secret=${secretKey}&issuer=${encodeURIComponent(issuer)}`;
+ if (algorithm !== TOTP_DEFAULT_ALGORITHM) {
+ uri += `&algorithm=${algorithm}`;
+ }
+ if (digits !== TOTP_DEFAULT_DIGITS) {
+ uri += `&digits=${digits}`;
+ }
+ if (period !== TOTP_DEFAULT_PERIOD) {
+ uri += `&period=${period}`;
+ }
+ return uri;
+}
diff --git a/apps/browser-extension/src/utils/db/queries/ItemQueries.ts b/apps/browser-extension/src/utils/db/queries/ItemQueries.ts
index c9c3eaf54..c4486e23e 100644
--- a/apps/browser-extension/src/utils/db/queries/ItemQueries.ts
+++ b/apps/browser-extension/src/utils/db/queries/ItemQueries.ts
@@ -436,7 +436,7 @@ export class TotpCodeQueries {
* so a bare `ItemId` match would pull in a same-id item's codes from another manifest.
*/
public static readonly GET_BY_ITEM_ID = `
- SELECT Id, Name, SecretKey, ItemId
+ SELECT Id, Name, SecretKey, Algorithm, Digits, Period, ItemId
FROM TotpCodes
WHERE ItemId = ? AND ManifestId = ? AND IsDeleted = 0`;
@@ -444,8 +444,8 @@ export class TotpCodeQueries {
* Insert a new TOTP code, stamped with the manifest of the item it hangs off.
*/
public static readonly INSERT = `
- INSERT INTO TotpCodes (Id, Name, SecretKey, ItemId, ManifestId, CreatedAt, UpdatedAt, IsDeleted)
- VALUES (?, ?, ?, ?, ${BaseQueries.MANIFEST_OF_ITEM}, ?, ?, ?)`;
+ INSERT INTO TotpCodes (Id, Name, SecretKey, Algorithm, Digits, Period, ItemId, ManifestId, CreatedAt, UpdatedAt, IsDeleted)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ${BaseQueries.MANIFEST_OF_ITEM}, ?, ?, ?)`;
/**
* Update an existing TOTP code.
@@ -454,6 +454,9 @@ export class TotpCodeQueries {
UPDATE TotpCodes
SET Name = ?,
SecretKey = ?,
+ Algorithm = ?,
+ Digits = ?,
+ Period = ?,
UpdatedAt = ?
WHERE Id = ? AND ManifestId = ?`;
diff --git a/apps/browser-extension/src/utils/db/repositories/ItemRepository.ts b/apps/browser-extension/src/utils/db/repositories/ItemRepository.ts
index 8f92d752e..e6ec3194d 100644
--- a/apps/browser-extension/src/utils/db/repositories/ItemRepository.ts
+++ b/apps/browser-extension/src/utils/db/repositories/ItemRepository.ts
@@ -1,5 +1,5 @@
import type { Item, ItemField, Attachment, TotpCode, FieldHistory, LogoSelection } from '@/utils/dist/core/models/vault';
-import { FieldKey, LogoKinds, MAX_FIELD_HISTORY_RECORDS } from '@/utils/dist/core/models/vault';
+import { FieldKey, LogoKinds, MAX_FIELD_HISTORY_RECORDS, normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod } from '@/utils/dist/core/models/vault';
import { getFolderPath } from '@/utils/FolderUtils';
import { BaseRepository, type IDatabaseClient } from '../BaseRepository';
@@ -346,8 +346,8 @@ export class ItemRepository extends BaseRepository {
const childCopies = [
{
table: 'TotpCodes',
- sql: `INSERT INTO TotpCodes (Id, ItemId, ManifestId, Name, SecretKey, CreatedAt, UpdatedAt, IsDeleted)
- SELECT ?, ?, ManifestId, Name, SecretKey, ?, ?, 0 FROM TotpCodes WHERE Id = ? AND ManifestId = ?`,
+ sql: `INSERT INTO TotpCodes (Id, ItemId, ManifestId, Name, SecretKey, Algorithm, Digits, Period, CreatedAt, UpdatedAt, IsDeleted)
+ SELECT ?, ?, ManifestId, Name, SecretKey, Algorithm, Digits, Period, ?, ?, 0 FROM TotpCodes WHERE Id = ? AND ManifestId = ?`,
},
{
table: 'Attachments',
@@ -1154,6 +1154,9 @@ export class ItemRepository extends BaseRepository {
totpCode.Id || this.generateId(),
totpCode.Name,
totpCode.SecretKey,
+ normalizeTotpAlgorithm(totpCode.Algorithm),
+ normalizeTotpDigits(totpCode.Digits),
+ normalizeTotpPeriod(totpCode.Period),
itemId,
itemId,
this.activeManifestId(),
@@ -1193,10 +1196,16 @@ export class ItemRepository extends BaseRepository {
} else if (wasOriginal) {
// Only update if values actually changed
const existing = existingByIdMap.get(totpCode.Id);
- if (existing && (existing.Name !== totpCode.Name || existing.SecretKey !== totpCode.SecretKey)) {
+ const algorithm = normalizeTotpAlgorithm(totpCode.Algorithm);
+ const digits = normalizeTotpDigits(totpCode.Digits);
+ const period = normalizeTotpPeriod(totpCode.Period);
+ const changed = existing && (existing.Name !== totpCode.Name || existing.SecretKey !== totpCode.SecretKey ||
+ existing.Algorithm !== algorithm || existing.Digits !== digits || existing.Period !== period);
+
+ if (changed) {
this.client.executeUpdate(
TotpCodeQueries.UPDATE,
- [totpCode.Name, totpCode.SecretKey, currentDateTime, totpCode.Id, manifestId]
+ [totpCode.Name, totpCode.SecretKey, algorithm, digits, period, currentDateTime, totpCode.Id, manifestId]
);
}
} else {
@@ -1206,6 +1215,9 @@ export class ItemRepository extends BaseRepository {
totpCode.Id || this.generateId(),
totpCode.Name,
totpCode.SecretKey,
+ normalizeTotpAlgorithm(totpCode.Algorithm),
+ normalizeTotpDigits(totpCode.Digits),
+ normalizeTotpPeriod(totpCode.Period),
itemId,
itemId,
this.activeManifestId(),
diff --git a/apps/browser-extension/src/utils/dist/core/models/vault/index.d.ts b/apps/browser-extension/src/utils/dist/core/models/vault/index.d.ts
index c8d607f49..da0241ab8 100644
--- a/apps/browser-extension/src/utils/dist/core/models/vault/index.d.ts
+++ b/apps/browser-extension/src/utils/dist/core/models/vault/index.d.ts
@@ -92,11 +92,47 @@ type TotpCode = {
Name: string;
/** The secret key for the TOTP code */
SecretKey: string;
+ /** The HMAC algorithm used to derive the code: SHA1, SHA256 or SHA512 */
+ Algorithm: string;
+ /** The number of digits in the generated code, typically 6 or 8 */
+ Digits: number;
+ /** The time step in seconds a code stays valid for, typically 30 or 60 */
+ Period: number;
/** The item ID this TOTP code belongs to */
ItemId: string;
/** Whether the TOTP code has been deleted (soft delete) */
IsDeleted?: boolean;
};
+/** The HMAC algorithm RFC 6238 assumes when an otpauth:// URI omits the `algorithm` parameter. */
+declare const TOTP_DEFAULT_ALGORITHM = "SHA1";
+/** The code length RFC 6238 assumes when an otpauth:// URI omits the `digits` parameter. */
+declare const TOTP_DEFAULT_DIGITS = 6;
+/** The time step RFC 6238 assumes when an otpauth:// URI omits the `period` parameter. */
+declare const TOTP_DEFAULT_PERIOD = 30;
+/** The HMAC algorithms the TOTP generators implement. Anything else falls back to {@link TOTP_DEFAULT_ALGORITHM}. */
+declare const TOTP_SUPPORTED_ALGORITHMS: readonly ["SHA1", "SHA256", "SHA512"];
+/**
+ * Normalizes a raw `algorithm` value (from an otpauth:// URI or an older vault row) to one of
+ * {@link TOTP_SUPPORTED_ALGORITHMS}, falling back to {@link TOTP_DEFAULT_ALGORITHM}.
+ *
+ * @param value - Raw algorithm value, e.g. "sha256" or undefined
+ * @returns A supported algorithm name in uppercase
+ */
+declare function normalizeTotpAlgorithm(value: string | null | undefined): string;
+/**
+ * Normalizes a raw `digits` value to a supported code length (6-10), falling back to {@link TOTP_DEFAULT_DIGITS}.
+ *
+ * @param value - Raw digits value, e.g. "8" or undefined
+ * @returns A usable digit count
+ */
+declare function normalizeTotpDigits(value: string | number | null | undefined): number;
+/**
+ * Normalizes a raw `period` value to a positive time step, falling back to {@link TOTP_DEFAULT_PERIOD}.
+ *
+ * @param value - Raw period value, e.g. "60" or undefined
+ * @returns A usable period in seconds
+ */
+declare function normalizeTotpPeriod(value: string | number | null | undefined): number;
/**
* Credential SQLite database type.
@@ -660,4 +696,4 @@ type FieldHistory = {
*/
declare const MAX_FIELD_HISTORY_RECORDS = 10;
-export { type Alias, type Attachment, type CreateCustomFieldOptions, type CreateSystemFieldOptions, type Credential, type DicewareCapitalization, type DicewareSalt, type DicewareSeparator, type EncryptionKey, FieldCategories, type FieldCategory, type FieldHistory, FieldKey, type FieldKeyValue, type FieldType, FieldTypes, type Item, type ItemField, type ItemLogo, type ItemTag, type ItemTagRef, type ItemType, type ItemTypeFieldConfig, ItemTypes, type LogoKind, LogoKinds, type LogoSelection, MAX_FIELD_HISTORY_RECORDS, type Passkey, type PasswordGeneratorType, type PasswordSettings, type SystemFieldDefinition, SystemFieldRegistry, type Tag, type TotpCode, VaultDataBucketCategory, type VaultDataBucketCategoryValue, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential };
+export { type Alias, type Attachment, type CreateCustomFieldOptions, type CreateSystemFieldOptions, type Credential, type DicewareCapitalization, type DicewareSalt, type DicewareSeparator, type EncryptionKey, FieldCategories, type FieldCategory, type FieldHistory, FieldKey, type FieldKeyValue, type FieldType, FieldTypes, type Item, type ItemField, type ItemLogo, type ItemTag, type ItemTagRef, type ItemType, type ItemTypeFieldConfig, ItemTypes, type LogoKind, LogoKinds, type LogoSelection, MAX_FIELD_HISTORY_RECORDS, type Passkey, type PasswordGeneratorType, type PasswordSettings, type SystemFieldDefinition, SystemFieldRegistry, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD, TOTP_SUPPORTED_ALGORITHMS, type Tag, type TotpCode, VaultDataBucketCategory, type VaultDataBucketCategoryValue, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential, normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod };
diff --git a/apps/browser-extension/src/utils/dist/core/models/vault/index.js b/apps/browser-extension/src/utils/dist/core/models/vault/index.js
index 7bfa375b3..ac22860f2 100644
--- a/apps/browser-extension/src/utils/dist/core/models/vault/index.js
+++ b/apps/browser-extension/src/utils/dist/core/models/vault/index.js
@@ -2,6 +2,24 @@
// This file was automatically generated. Do not edit manually.
+// src/vault/TotpCode.ts
+var TOTP_DEFAULT_ALGORITHM = "SHA1";
+var TOTP_DEFAULT_DIGITS = 6;
+var TOTP_DEFAULT_PERIOD = 30;
+var TOTP_SUPPORTED_ALGORITHMS = ["SHA1", "SHA256", "SHA512"];
+function normalizeTotpAlgorithm(value) {
+ const normalized = (value ?? "").trim().toUpperCase().replace(/[-_\s]/g, "");
+ return TOTP_SUPPORTED_ALGORITHMS.includes(normalized) ? normalized : TOTP_DEFAULT_ALGORITHM;
+}
+function normalizeTotpDigits(value) {
+ const parsed = typeof value === "number" ? value : parseInt(String(value ?? ""), 10);
+ return Number.isInteger(parsed) && parsed >= 6 && parsed <= 10 ? parsed : TOTP_DEFAULT_DIGITS;
+}
+function normalizeTotpPeriod(value) {
+ const parsed = typeof value === "number" ? value : parseInt(String(value ?? ""), 10);
+ return Number.isInteger(parsed) && parsed > 0 && parsed <= 300 ? parsed : TOTP_DEFAULT_PERIOD;
+}
+
// src/vault/FieldKey.ts
var FieldKey = {
/**
@@ -463,4 +481,4 @@ function createCustomField(options) {
// src/vault/FieldHistory.ts
var MAX_FIELD_HISTORY_RECORDS = 10;
-export { FieldCategories, FieldKey, FieldTypes, ItemTypes, LogoKinds, MAX_FIELD_HISTORY_RECORDS, SystemFieldRegistry, VaultDataBucketCategory, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential };
+export { FieldCategories, FieldKey, FieldTypes, ItemTypes, LogoKinds, MAX_FIELD_HISTORY_RECORDS, SystemFieldRegistry, TOTP_DEFAULT_ALGORITHM, TOTP_DEFAULT_DIGITS, TOTP_DEFAULT_PERIOD, TOTP_SUPPORTED_ALGORITHMS, VaultDataBucketCategory, createCustomField, createSystemField, fieldAppliesToType, getAllSystemFieldKeys, getDefaultFieldsForItemType, getFieldConfigForType, getFieldValue, getFieldValues, getOptionalFieldsForItemType, getSystemField, getSystemFieldsForItemType, groupFields, groupFieldsByCategory, hasField, isFieldShownByDefault, isSystemField, isSystemFieldPrefix, itemToCredential, normalizeTotpAlgorithm, normalizeTotpDigits, normalizeTotpPeriod };
diff --git a/apps/browser-extension/src/utils/dist/core/vault/index.d.mts b/apps/browser-extension/src/utils/dist/core/vault/index.d.mts
index 0d24f5c11..041fd6580 100644
--- a/apps/browser-extension/src/utils/dist/core/vault/index.d.mts
+++ b/apps/browser-extension/src/utils/dist/core/vault/index.d.mts
@@ -128,7 +128,7 @@ declare const VAULT_VERSIONS: VaultVersion[];
* Complete database schema SQL (latest version)
* Auto-generated from EF Core migrations
*/
-declare const COMPLETE_SCHEMA_SQL = "\n\uFEFFCREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\n \"MigrationId\" TEXT NOT NULL CONSTRAINT \"PK___EFMigrationsHistory\" PRIMARY KEY,\n \"ProductVersion\" TEXT NOT NULL\n);\n\nBEGIN TRANSACTION;\nCREATE TABLE \"Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"Gender\" VARCHAR NULL,\n \"FirstName\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"BirthDate\" TEXT NOT NULL,\n \"AddressStreet\" VARCHAR NULL,\n \"AddressCity\" VARCHAR NULL,\n \"AddressState\" VARCHAR NULL,\n \"AddressZipCode\" VARCHAR NULL,\n \"AddressCountry\" VARCHAR NULL,\n \"Hobbies\" TEXT NULL,\n \"EmailPrefix\" TEXT NULL,\n \"PhoneMobile\" TEXT NULL,\n \"BankAccountIBAN\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Services\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Services\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"Url\" TEXT NULL,\n \"Logo\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"Username\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"ServiceId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Attachment\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachment\" PRIMARY KEY,\n \"Filename\" TEXT NOT NULL,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachment_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Passwords\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passwords\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Passwords_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_Attachment_CredentialId\" ON \"Attachment\" (\"CredentialId\");\n\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\n\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\n\nCREATE INDEX \"IX_Passwords_CredentialId\" ON \"Passwords\" (\"CredentialId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240708094944_1.0.0-InitialMigration', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240708224522_1.0.1-EmptyTestMigration', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nALTER TABLE \"Aliases\" RENAME COLUMN \"EmailPrefix\" TO \"Email\";\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240711204207_1.0.2-ChangeEmailColumn', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"EncryptionKeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240729105618_1.1.0-AddPkiTables', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"Settings\" (\n \"Key\" TEXT NOT NULL CONSTRAINT \"PK_Settings\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240805073413_1.2.0-AddSettingsTable', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"BirthDate\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Email\" TEXT NULL,\n \"FirstName\" VARCHAR NULL,\n \"Gender\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"ef_temp_Aliases\" (\"Id\", \"BirthDate\", \"CreatedAt\", \"Email\", \"FirstName\", \"Gender\", \"LastName\", \"NickName\", \"UpdatedAt\")\nSELECT \"Id\", \"BirthDate\", \"CreatedAt\", \"Email\", \"FirstName\", \"Gender\", \"LastName\", \"NickName\", \"UpdatedAt\"\nFROM \"Aliases\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Aliases\";\n\nALTER TABLE \"ef_temp_Aliases\" RENAME TO \"Aliases\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240805122422_1.3.0-UpdateIdentityStructure', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"ServiceId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Username\" TEXT NULL,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Credentials\" (\"Id\", \"AliasId\", \"CreatedAt\", \"Notes\", \"ServiceId\", \"UpdatedAt\", \"Username\")\nSELECT \"Id\", \"AliasId\", \"CreatedAt\", \"Notes\", \"ServiceId\", \"UpdatedAt\", \"Username\"\nFROM \"Credentials\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Credentials\";\n\nALTER TABLE \"ef_temp_Credentials\" RENAME TO \"Credentials\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\n\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240812141727_1.3.1-MakeUsernameOptional', '10.0.10');\n\nBEGIN TRANSACTION;\nALTER TABLE \"Settings\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Services\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Passwords\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"EncryptionKeys\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Credentials\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Attachment\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Aliases\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240916105320_1.4.0-AddSyncSupport', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nALTER TABLE \"Attachment\" RENAME TO \"Attachments\";\n\nCREATE TABLE \"ef_temp_Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"Id\", \"Blob\", \"CreatedAt\", \"CredentialId\", \"Filename\", \"IsDeleted\", \"UpdatedAt\")\nSELECT \"Id\", \"Blob\", \"CreatedAt\", \"CredentialId\", \"Filename\", \"IsDeleted\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_CredentialId\" ON \"Attachments\" (\"CredentialId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240917191243_1.4.1-RenameAttachmentsPlural', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TABLE \"TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_TotpCodes_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_TotpCodes_CredentialId\" ON \"TotpCodes\" (\"CredentialId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20250310131554_1.5.0-AddTotpCodes', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\n\nPRAGMA foreign_keys = OFF;\n\n-- Clean up any existing temp tables first\nDROP TABLE IF EXISTS \"__EFMigrationsHistory_temp\";\nDROP TABLE IF EXISTS \"Aliases_temp\";\nDROP TABLE IF EXISTS \"Services_temp\";\nDROP TABLE IF EXISTS \"EncryptionKeys_temp\";\nDROP TABLE IF EXISTS \"Settings_temp\";\nDROP TABLE IF EXISTS \"Credentials_temp\";\nDROP TABLE IF EXISTS \"Attachments_temp\";\nDROP TABLE IF EXISTS \"Passwords_temp\";\nDROP TABLE IF EXISTS \"TotpCodes_temp\";\n\n-- Create backup tables for all data\nCREATE TABLE \"__EFMigrationsHistory_temp\" AS SELECT * FROM \"__EFMigrationsHistory\";\nCREATE TABLE \"Aliases_temp\" AS SELECT * FROM \"Aliases\";\nCREATE TABLE \"Services_temp\" AS SELECT * FROM \"Services\";\nCREATE TABLE \"EncryptionKeys_temp\" AS SELECT * FROM \"EncryptionKeys\";\nCREATE TABLE \"Settings_temp\" AS SELECT * FROM \"Settings\";\nCREATE TABLE \"Credentials_temp\" AS SELECT * FROM \"Credentials\";\nCREATE TABLE \"Attachments_temp\" AS SELECT * FROM \"Attachments\";\nCREATE TABLE \"Passwords_temp\" AS SELECT * FROM \"Passwords\";\nCREATE TABLE \"TotpCodes_temp\" AS SELECT * FROM \"TotpCodes\";\n\n-- Delete orphaned records that do not have a valid FK to the credential object\nDELETE FROM \"Attachments_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"Passwords_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"TotpCodes_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\n\n-- Delete orphaned credentials that do not have valid FKs to alias or service objects\nDELETE FROM \"Credentials_temp\" WHERE \"AliasId\" NOT IN (SELECT \"Id\" FROM \"Aliases_temp\");\nDELETE FROM \"Credentials_temp\" WHERE \"ServiceId\" NOT IN (SELECT \"Id\" FROM \"Services_temp\");\n\n-- After cleaning credentials, clean dependent tables again in case we removed credentials\nDELETE FROM \"Attachments_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"Passwords_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"TotpCodes_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\n\n-- Drop all existing tables\nDROP TABLE \"TotpCodes\";\nDROP TABLE \"Passwords\";\nDROP TABLE \"Attachments\";\nDROP TABLE \"Credentials\";\nDROP TABLE \"Settings\";\nDROP TABLE \"EncryptionKeys\";\nDROP TABLE \"Services\";\nDROP TABLE \"Aliases\";\nDROP TABLE \"__EFMigrationsHistory\";\n\n-- Recreate tables with proper constraints (no dependencies first)\nCREATE TABLE \"__EFMigrationsHistory\" (\n \"MigrationId\" TEXT NOT NULL CONSTRAINT \"PK___EFMigrationsHistory\" PRIMARY KEY,\n \"ProductVersion\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"BirthDate\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Email\" TEXT NULL,\n \"FirstName\" VARCHAR NULL,\n \"Gender\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"Services\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Services\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"Url\" TEXT NULL,\n \"Logo\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"EncryptionKeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"Settings\" (\n \"Key\" TEXT NOT NULL CONSTRAINT \"PK_Settings\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\n-- Tables with foreign keys\nCREATE TABLE \"Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"ServiceId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Username\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Passwords\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passwords\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_Passwords_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_TotpCodes_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\n\n-- Restore data from temp tables\nINSERT INTO \"__EFMigrationsHistory\" SELECT * FROM \"__EFMigrationsHistory_temp\";\nINSERT INTO \"Aliases\" SELECT * FROM \"Aliases_temp\";\nINSERT INTO \"Services\" SELECT * FROM \"Services_temp\";\nINSERT INTO \"EncryptionKeys\" SELECT * FROM \"EncryptionKeys_temp\";\nINSERT INTO \"Settings\" SELECT * FROM \"Settings_temp\";\nINSERT INTO \"Credentials\" SELECT * FROM \"Credentials_temp\";\nINSERT INTO \"Attachments\" SELECT * FROM \"Attachments_temp\";\nINSERT INTO \"Passwords\" SELECT * FROM \"Passwords_temp\";\nINSERT INTO \"TotpCodes\" SELECT * FROM \"TotpCodes_temp\";\n\n-- =====================================================================================\n-- Date Format Normalization Migration\n-- =====================================================================================\n-- This migration normalizes ALL date fields to the standard format: 'yyyy-MM-dd HH:mm:ss.fff'\n-- Previously the different clients used different date formats which complicate date parsing.\n-- From version 0.24.0 onwards, all new dates are stored in this standard format.\n\n-- Update Aliases table (CreatedAt, UpdatedAt, BirthDate)\nUPDATE \"Aliases\" SET \"CreatedAt\" =\n CASE\n -- Already in correct format (yyyy-MM-dd HH:mm:ss.fff) - no change\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n\n -- ISO 8601 with milliseconds (yyyy-MM-ddTHH:mm:ss.fffZ) -> Replace T with space, remove Z and everything after .fff\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n\n -- Without milliseconds (yyyy-MM-dd HH:mm:ss or yyyy-MM-ddTHH:mm:ssZ) -> Add .000\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n\n -- Fallback: if none match, keep as-is (edge case)\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Aliases\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- BirthDate: Always set time to 00:00:00 (no milliseconds for birth dates)\nUPDATE \"Aliases\" SET \"BirthDate\" =\n CASE\n -- If empty or already '0001-01-01 00:00:00', keep as-is\n WHEN \"BirthDate\" = '' OR \"BirthDate\" = '0001-01-01 00:00:00'\n THEN \"BirthDate\"\n\n -- If already in correct format (yyyy-MM-dd 00:00:00), keep as-is\n WHEN \"BirthDate\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] 00:00:00'\n THEN \"BirthDate\"\n\n -- Extract date part and set time to 00:00:00\n WHEN \"BirthDate\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*'\n THEN substr(\"BirthDate\", 1, 10) || ' 00:00:00'\n\n -- Fallback\n ELSE \"BirthDate\"\n END;\n\n-- Update Services table (CreatedAt, UpdatedAt)\nUPDATE \"Services\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Services\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update EncryptionKeys table (CreatedAt, UpdatedAt)\nUPDATE \"EncryptionKeys\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"EncryptionKeys\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Settings table (CreatedAt, UpdatedAt)\nUPDATE \"Settings\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Settings\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Credentials table (CreatedAt, UpdatedAt)\nUPDATE \"Credentials\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Credentials\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Attachments table (CreatedAt, UpdatedAt)\nUPDATE \"Attachments\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Attachments\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Passwords table (CreatedAt, UpdatedAt)\nUPDATE \"Passwords\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Passwords\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update TotpCodes table (CreatedAt, UpdatedAt)\nUPDATE \"TotpCodes\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"TotpCodes\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- =====================================================================================\n-- End of Date Format Normalization Migration\n-- =====================================================================================\n\n-- Recreate indexes\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\nCREATE INDEX \"IX_Attachments_CredentialId\" ON \"Attachments\" (\"CredentialId\");\nCREATE INDEX \"IX_Passwords_CredentialId\" ON \"Passwords\" (\"CredentialId\");\nCREATE INDEX \"IX_TotpCodes_CredentialId\" ON \"TotpCodes\" (\"CredentialId\");\n\n-- Clean up temp tables\nDROP TABLE \"__EFMigrationsHistory_temp\";\nDROP TABLE \"Aliases_temp\";\nDROP TABLE \"Services_temp\";\nDROP TABLE \"EncryptionKeys_temp\";\nDROP TABLE \"Settings_temp\";\nDROP TABLE \"Credentials_temp\";\nDROP TABLE \"Attachments_temp\";\nDROP TABLE \"Passwords_temp\";\nDROP TABLE \"TotpCodes_temp\";\n\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"Passkeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passkeys\" PRIMARY KEY,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"AdditionalData\" BLOB NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Passkeys_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_Passkeys_CredentialId\" ON \"Passkeys\" (\"CredentialId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20251014122838_1.6.0-AddPasskeys', '10.0.10');\n\nCOMMIT;\n\nPRAGMA foreign_keys = OFF;\n\nBEGIN TRANSACTION;\nALTER TABLE \"TotpCodes\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_TotpCodes_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_TotpCodes_ItemId\" ON \"TotpCodes\" (\"ItemId\");\n\nALTER TABLE \"Passkeys\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_Passkeys_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_Passkeys_ItemId\" ON \"Passkeys\" (\"ItemId\");\n\nALTER TABLE \"Attachments\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_Attachments_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_Attachments_ItemId\" ON \"Attachments\" (\"ItemId\");\n\nCREATE TABLE \"FieldDefinitions\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldDefinitions\" PRIMARY KEY,\n \"FieldType\" TEXT NOT NULL,\n \"Label\" TEXT NOT NULL,\n \"IsMultiValue\" INTEGER NOT NULL,\n \"IsHidden\" INTEGER NOT NULL,\n \"EnableHistory\" INTEGER NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"ApplicableToTypes\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Folders\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Folders\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"ParentFolderId\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Folders_Folders_ParentFolderId\" FOREIGN KEY (\"ParentFolderId\") REFERENCES \"Folders\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Logos\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Logos\" PRIMARY KEY,\n \"Source\" TEXT NOT NULL,\n \"FileData\" BLOB NULL,\n \"MimeType\" TEXT NULL,\n \"FetchedAt\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Tags\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Tags\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"Color\" TEXT NULL,\n \"DisplayOrder\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Items\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Items\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"ItemType\" TEXT NOT NULL,\n \"LogoId\" TEXT NULL,\n \"DeletedAt\" TEXT NULL,\n \"FolderId\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Items_Folders_FolderId\" FOREIGN KEY (\"FolderId\") REFERENCES \"Folders\" (\"Id\") ON DELETE SET NULL,\n CONSTRAINT \"FK_Items_Logos_LogoId\" FOREIGN KEY (\"LogoId\") REFERENCES \"Logos\" (\"Id\") ON DELETE SET NULL\n);\n\nCREATE TABLE \"FieldHistories\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldHistories\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"ValueSnapshot\" TEXT NOT NULL,\n \"ChangedAt\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_FieldHistories_FieldDefinitions_FieldDefinitionId\" FOREIGN KEY (\"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldHistories_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"FieldValues\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldValues\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"Value\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_FieldValues_FieldDefinitions_FieldDefinitionId\" FOREIGN KEY (\"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldValues_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"ItemTags\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_ItemTags\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"TagId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_ItemTags_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_ItemTags_Tags_TagId\" FOREIGN KEY (\"TagId\") REFERENCES \"Tags\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_FieldHistories_FieldDefinitionId\" ON \"FieldHistories\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ItemId\" ON \"FieldHistories\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_FieldDefinitionId\" ON \"FieldValues\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_FieldKey\" ON \"FieldValues\" (\"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ItemId\" ON \"FieldValues\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldDefinitionId_Weight\" ON \"FieldValues\" (\"ItemId\", \"FieldDefinitionId\", \"Weight\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldKey\" ON \"FieldValues\" (\"ItemId\", \"FieldKey\");\n\nCREATE INDEX \"IX_Folders_ParentFolderId\" ON \"Folders\" (\"ParentFolderId\");\n\nCREATE INDEX \"IX_Items_FolderId\" ON \"Items\" (\"FolderId\");\n\nCREATE INDEX \"IX_Items_LogoId\" ON \"Items\" (\"LogoId\");\n\nCREATE INDEX \"IX_ItemTags_ItemId\" ON \"ItemTags\" (\"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ItemId_TagId\" ON \"ItemTags\" (\"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_TagId\" ON \"ItemTags\" (\"TagId\");\n\nCREATE UNIQUE INDEX \"IX_Logos_Source\" ON \"Logos\" (\"Source\");\n\nCREATE INDEX \"IX_Tags_Name\" ON \"Tags\" (\"Name\");\n\n\n INSERT INTO Items (Id, Name, ItemType, LogoId, FolderId, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n c.Id,\n s.Name AS Name,\n CASE\n WHEN a.Id IS NOT NULL AND (\n (a.FirstName IS NOT NULL AND a.FirstName != '') OR\n (a.LastName IS NOT NULL AND a.LastName != '') OR\n (a.Gender IS NOT NULL AND a.Gender != '') OR\n (a.BirthDate IS NOT NULL AND a.BirthDate != '' AND a.BirthDate NOT LIKE '0001-%')\n ) THEN 'Alias'\n ELSE 'Login'\n END AS ItemType,\n NULL AS LogoId,\n NULL AS FolderId,\n c.CreatedAt,\n c.UpdatedAt,\n c.IsDeleted\n FROM Credentials c\n LEFT JOIN Services s ON s.Id = c.ServiceId\n LEFT JOIN Aliases a ON a.Id = c.AliasId;\n \n\n\n INSERT INTO Logos (Id, Source, FileData, MimeType, FetchedAt, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n -- Extract and normalize hostname: remove protocol, path, lowercase, and www. prefix\n REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n ) AS Source,\n s.Logo AS FileData,\n 'image/png' AS MimeType,\n NULL AS FetchedAt,\n MIN(s.CreatedAt) AS CreatedAt,\n MAX(s.UpdatedAt) AS UpdatedAt,\n 0 AS IsDeleted\n FROM Services s\n WHERE s.Logo IS NOT NULL AND s.Url IS NOT NULL AND s.Url != ''\n GROUP BY REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n );\n \n\n\n UPDATE Items\n SET LogoId = (\n SELECT l.Id FROM Logos l\n INNER JOIN Services s ON REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n ) = l.Source\n INNER JOIN Credentials c ON c.ServiceId = s.Id\n WHERE c.Id = Items.Id\n LIMIT 1\n )\n WHERE EXISTS (\n SELECT 1 FROM Credentials c\n INNER JOIN Services s ON s.Id = c.ServiceId\n WHERE c.Id = Items.Id AND s.Logo IS NOT NULL\n );\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.url' AS FieldKey,\n s.Url AS Value,\n 0 AS Weight,\n s.UpdatedAt AS CreatedAt,\n s.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Services s ON s.Id = c.ServiceId\n WHERE s.Url IS NOT NULL AND s.Url != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.username' AS FieldKey,\n c.Username AS Value,\n 0 AS Weight,\n c.UpdatedAt AS CreatedAt,\n c.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n WHERE c.Username IS NOT NULL AND c.Username != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'notes.content' AS FieldKey,\n c.Notes AS Value,\n 0 AS Weight,\n c.UpdatedAt AS CreatedAt,\n c.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n WHERE c.Notes IS NOT NULL AND c.Notes != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n p.CredentialId AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.password' AS FieldKey,\n p.Value AS Value,\n 0 AS Weight,\n p.UpdatedAt AS CreatedAt,\n p.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Passwords p\n INNER JOIN (\n SELECT CredentialId, MAX(UpdatedAt) AS MaxUpdated, MAX(Id) AS MaxId\n FROM Passwords\n WHERE IsDeleted = 0\n GROUP BY CredentialId\n ) pm ON p.CredentialId = pm.CredentialId AND p.UpdatedAt = pm.MaxUpdated AND p.Id = pm.MaxId\n WHERE p.IsDeleted = 0;\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.email' AS FieldKey,\n a.Email AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.Email IS NOT NULL AND a.Email != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.first_name' AS FieldKey,\n a.FirstName AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.FirstName IS NOT NULL AND a.FirstName != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.last_name' AS FieldKey,\n a.LastName AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.LastName IS NOT NULL AND a.LastName != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.gender' AS FieldKey,\n a.Gender AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.Gender IS NOT NULL AND a.Gender != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.birthdate' AS FieldKey,\n SUBSTR(a.BirthDate, 1, 10) AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.BirthDate IS NOT NULL AND a.BirthDate != '' AND a.BirthDate NOT LIKE '0001-%';\n \n\nDROP TABLE \"Passwords\";\n\nDROP TABLE \"Credentials\";\n\nDROP TABLE \"Aliases\";\n\nDROP TABLE \"Services\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = ON;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\")\nSELECT \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCREATE TABLE \"ef_temp_Passkeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passkeys\" PRIMARY KEY,\n \"AdditionalData\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n CONSTRAINT \"FK_Passkeys_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Passkeys\" (\"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\")\nSELECT \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\"\nFROM \"Passkeys\";\n\nCREATE TABLE \"ef_temp_TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_TotpCodes_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_TotpCodes\" (\"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\")\nSELECT \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\"\nFROM \"TotpCodes\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nDROP TABLE \"Passkeys\";\n\nALTER TABLE \"ef_temp_Passkeys\" RENAME TO \"Passkeys\";\n\nDROP TABLE \"TotpCodes\";\n\nALTER TABLE \"ef_temp_TotpCodes\" RENAME TO \"TotpCodes\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_ItemId\" ON \"Attachments\" (\"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_ItemId\" ON \"Passkeys\" (\"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nCREATE INDEX \"IX_TotpCodes_ItemId\" ON \"TotpCodes\" (\"ItemId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20251213111207_1.7.0-FieldBasedDataModelUpdate', '10.0.10');\n\nBEGIN TRANSACTION;\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260130221620_2.0.0-MajorVersionBump', '10.0.10');\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP INDEX \"IX_TotpCodes_ItemId\";\n\nDROP INDEX \"IX_Tags_Name\";\n\nDROP INDEX \"IX_Passkeys_ItemId\";\n\nDROP INDEX \"IX_Logos_Source\";\n\nDROP INDEX \"IX_ItemTags_ItemId_TagId\";\n\nDROP INDEX \"IX_Items_FolderId\";\n\nDROP INDEX \"IX_Items_LogoId\";\n\nDROP INDEX \"IX_Attachments_ItemId\";\n\nALTER TABLE \"TotpCodes\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Tags\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Settings\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Passkeys\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Logos\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Logos\" ADD \"Kind\" TEXT NOT NULL DEFAULT 'favicon';\n\nALTER TABLE \"Logos\" ADD \"Name\" TEXT NULL;\n\nALTER TABLE \"ItemTags\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Items\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Folders\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldValues\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldHistories\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldDefinitions\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"EncryptionKeys\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Attachments\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nCREATE TABLE \"CodecOverflows\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_CodecOverflows\" PRIMARY KEY,\n \"Data\" TEXT NOT NULL\n);\n\nCREATE TABLE \"ItemStats\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"LastUsedAt\" TEXT NULL,\n \"UseCount\" INTEGER NOT NULL,\n \"LastAutofilledAt\" TEXT NULL,\n \"AutofillCount\" INTEGER NOT NULL,\n \"LastCopiedAt\" TEXT NULL,\n \"CopyCount\" INTEGER NOT NULL,\n \"LastPasskeyAuthAt\" TEXT NULL,\n \"PasskeyAuthCount\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"PK_ItemStats\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nCREATE TABLE \"Manifests\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Manifests\" PRIMARY KEY,\n \"Name\" TEXT NULL\n);\n\nCREATE INDEX \"IX_TotpCodes_ManifestId_ItemId\" ON \"TotpCodes\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Tags_ManifestId_Name\" ON \"Tags\" (\"ManifestId\", \"Name\");\n\nCREATE INDEX \"IX_Passkeys_ManifestId_ItemId\" ON \"Passkeys\" (\"ManifestId\", \"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_Logos_ManifestId_Kind_Source\" ON \"Logos\" (\"ManifestId\", \"Kind\", \"Source\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ManifestId_ItemId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_ManifestId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"TagId\");\n\nCREATE INDEX \"IX_Items_ManifestId_FolderId\" ON \"Items\" (\"ManifestId\", \"FolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_LogoId\" ON \"Items\" (\"ManifestId\", \"LogoId\");\n\nCREATE INDEX \"IX_Folders_ManifestId_ParentFolderId\" ON \"Folders\" (\"ManifestId\", \"ParentFolderId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_FieldDefinitionId\" ON \"FieldValues\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_ItemId\" ON \"FieldValues\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_FieldDefinitionId\" ON \"FieldHistories\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_ItemId\" ON \"FieldHistories\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_EncryptionKeys_ManifestId_IsPrimary\" ON \"EncryptionKeys\" (\"ManifestId\", \"IsPrimary\");\n\nCREATE INDEX \"IX_Attachments_ManifestId_ItemId\" ON \"Attachments\" (\"ManifestId\", \"ItemId\");\n\nCREATE TABLE \"ef_temp_Attachments\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Attachments\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Attachments_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"ManifestId\", \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCREATE TABLE \"ef_temp_FieldHistories\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"ChangedAt\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"ValueSnapshot\" TEXT NOT NULL,\n CONSTRAINT \"PK_FieldHistories\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_FieldHistories_FieldDefinitions_ManifestId_FieldDefinitionId\" FOREIGN KEY (\"ManifestId\", \"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldHistories_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_FieldHistories\" (\"ManifestId\", \"Id\", \"ChangedAt\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"ValueSnapshot\")\nSELECT \"ManifestId\", \"Id\", \"ChangedAt\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"ValueSnapshot\"\nFROM \"FieldHistories\";\n\nCREATE TABLE \"ef_temp_FieldValues\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Value\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_FieldValues\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_FieldValues_FieldDefinitions_ManifestId_FieldDefinitionId\" FOREIGN KEY (\"ManifestId\", \"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldValues_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_FieldValues\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"Value\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"Value\", \"Weight\"\nFROM \"FieldValues\";\n\nCREATE TABLE \"ef_temp_Folders\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"ParentFolderId\" TEXT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_Folders\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Folders_Folders_ManifestId_ParentFolderId\" FOREIGN KEY (\"ManifestId\", \"ParentFolderId\") REFERENCES \"Folders\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Folders\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"Name\", \"ParentFolderId\", \"UpdatedAt\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"Name\", \"ParentFolderId\", \"UpdatedAt\", \"Weight\"\nFROM \"Folders\";\n\nCREATE TABLE \"ef_temp_Items\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DeletedAt\" TEXT NULL,\n \"FolderId\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemType\" TEXT NOT NULL,\n \"LogoId\" TEXT NULL,\n \"Name\" TEXT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Items\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Items_Folders_ManifestId_FolderId\" FOREIGN KEY (\"ManifestId\", \"FolderId\") REFERENCES \"Folders\" (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Items_Logos_ManifestId_LogoId\" FOREIGN KEY (\"ManifestId\", \"LogoId\") REFERENCES \"Logos\" (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Items\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"DeletedAt\", \"FolderId\", \"IsDeleted\", \"ItemType\", \"LogoId\", \"Name\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"DeletedAt\", \"FolderId\", \"IsDeleted\", \"ItemType\", \"LogoId\", \"Name\", \"UpdatedAt\"\nFROM \"Items\";\n\nCREATE TABLE \"ef_temp_ItemTags\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"TagId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_ItemTags\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_ItemTags_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_ItemTags_Tags_ManifestId_TagId\" FOREIGN KEY (\"ManifestId\", \"TagId\") REFERENCES \"Tags\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_ItemTags\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"TagId\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"TagId\", \"UpdatedAt\"\nFROM \"ItemTags\";\n\nCREATE TABLE \"ef_temp_Passkeys\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"AdditionalData\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n CONSTRAINT \"PK_Passkeys\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Passkeys_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Passkeys\" (\"ManifestId\", \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\")\nSELECT \"ManifestId\", \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\"\nFROM \"Passkeys\";\n\nCREATE TABLE \"ef_temp_TotpCodes\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_TotpCodes_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_TotpCodes\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\"\nFROM \"TotpCodes\";\n\nCREATE TABLE \"ef_temp_Tags\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"Color\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayOrder\" INTEGER NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Tags\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Tags\" (\"ManifestId\", \"Id\", \"Color\", \"CreatedAt\", \"DisplayOrder\", \"IsDeleted\", \"Name\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"Color\", \"CreatedAt\", \"DisplayOrder\", \"IsDeleted\", \"Name\", \"UpdatedAt\"\nFROM \"Tags\";\n\nCREATE TABLE \"ef_temp_Settings\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Key\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Value\" TEXT NULL,\n CONSTRAINT \"PK_Settings\" PRIMARY KEY (\"ManifestId\", \"Key\")\n);\n\nINSERT INTO \"ef_temp_Settings\" (\"ManifestId\", \"Key\", \"CreatedAt\", \"IsDeleted\", \"UpdatedAt\", \"Value\")\nSELECT \"ManifestId\", \"Key\", \"CreatedAt\", \"IsDeleted\", \"UpdatedAt\", \"Value\"\nFROM \"Settings\";\n\nCREATE TABLE \"ef_temp_Logos\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FetchedAt\" TEXT NULL,\n \"FileData\" BLOB NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Kind\" TEXT NOT NULL DEFAULT 'favicon',\n \"MimeType\" TEXT NULL,\n \"Name\" TEXT NULL,\n \"Source\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Logos\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Logos\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"FetchedAt\", \"FileData\", \"IsDeleted\", \"Kind\", \"MimeType\", \"Name\", \"Source\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"FetchedAt\", \"FileData\", \"IsDeleted\", \"Kind\", \"MimeType\", \"Name\", \"Source\", \"UpdatedAt\"\nFROM \"Logos\";\n\nCREATE TABLE \"ef_temp_FieldDefinitions\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"ApplicableToTypes\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"EnableHistory\" INTEGER NOT NULL,\n \"FieldType\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"IsHidden\" INTEGER NOT NULL,\n \"IsMultiValue\" INTEGER NOT NULL,\n \"Label\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_FieldDefinitions\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_FieldDefinitions\" (\"ManifestId\", \"Id\", \"ApplicableToTypes\", \"CreatedAt\", \"EnableHistory\", \"FieldType\", \"IsDeleted\", \"IsHidden\", \"IsMultiValue\", \"Label\", \"UpdatedAt\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"ApplicableToTypes\", \"CreatedAt\", \"EnableHistory\", \"FieldType\", \"IsDeleted\", \"IsHidden\", \"IsMultiValue\", \"Label\", \"UpdatedAt\", \"Weight\"\nFROM \"FieldDefinitions\";\n\nCREATE TABLE \"ef_temp_EncryptionKeys\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_EncryptionKeys\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"IsPrimary\", \"PrivateKey\", \"PublicKey\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"IsPrimary\", \"PrivateKey\", \"PublicKey\", \"UpdatedAt\"\nFROM \"EncryptionKeys\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nDROP TABLE \"FieldHistories\";\n\nALTER TABLE \"ef_temp_FieldHistories\" RENAME TO \"FieldHistories\";\n\nDROP TABLE \"FieldValues\";\n\nALTER TABLE \"ef_temp_FieldValues\" RENAME TO \"FieldValues\";\n\nDROP TABLE \"Folders\";\n\nALTER TABLE \"ef_temp_Folders\" RENAME TO \"Folders\";\n\nDROP TABLE \"Items\";\n\nALTER TABLE \"ef_temp_Items\" RENAME TO \"Items\";\n\nDROP TABLE \"ItemTags\";\n\nALTER TABLE \"ef_temp_ItemTags\" RENAME TO \"ItemTags\";\n\nDROP TABLE \"Passkeys\";\n\nALTER TABLE \"ef_temp_Passkeys\" RENAME TO \"Passkeys\";\n\nDROP TABLE \"TotpCodes\";\n\nALTER TABLE \"ef_temp_TotpCodes\" RENAME TO \"TotpCodes\";\n\nDROP TABLE \"Tags\";\n\nALTER TABLE \"ef_temp_Tags\" RENAME TO \"Tags\";\n\nDROP TABLE \"Settings\";\n\nALTER TABLE \"ef_temp_Settings\" RENAME TO \"Settings\";\n\nDROP TABLE \"Logos\";\n\nALTER TABLE \"ef_temp_Logos\" RENAME TO \"Logos\";\n\nDROP TABLE \"FieldDefinitions\";\n\nALTER TABLE \"ef_temp_FieldDefinitions\" RENAME TO \"FieldDefinitions\";\n\nDROP TABLE \"EncryptionKeys\";\n\nALTER TABLE \"ef_temp_EncryptionKeys\" RENAME TO \"EncryptionKeys\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_ManifestId_ItemId\" ON \"Attachments\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_FieldDefinitionId\" ON \"FieldHistories\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ItemId\" ON \"FieldHistories\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_FieldDefinitionId\" ON \"FieldHistories\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_ItemId\" ON \"FieldHistories\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_FieldDefinitionId\" ON \"FieldValues\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_FieldKey\" ON \"FieldValues\" (\"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ItemId\" ON \"FieldValues\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldDefinitionId_Weight\" ON \"FieldValues\" (\"ItemId\", \"FieldDefinitionId\", \"Weight\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldKey\" ON \"FieldValues\" (\"ItemId\", \"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_FieldDefinitionId\" ON \"FieldValues\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_ItemId\" ON \"FieldValues\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Folders_ManifestId_ParentFolderId\" ON \"Folders\" (\"ManifestId\", \"ParentFolderId\");\n\nCREATE INDEX \"IX_Folders_ParentFolderId\" ON \"Folders\" (\"ParentFolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_FolderId\" ON \"Items\" (\"ManifestId\", \"FolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_LogoId\" ON \"Items\" (\"ManifestId\", \"LogoId\");\n\nCREATE INDEX \"IX_ItemTags_ItemId\" ON \"ItemTags\" (\"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ManifestId_ItemId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_ManifestId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_TagId\" ON \"ItemTags\" (\"TagId\");\n\nCREATE INDEX \"IX_Passkeys_ManifestId_ItemId\" ON \"Passkeys\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nCREATE INDEX \"IX_TotpCodes_ManifestId_ItemId\" ON \"TotpCodes\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Tags_ManifestId_Name\" ON \"Tags\" (\"ManifestId\", \"Name\");\n\nCREATE UNIQUE INDEX \"IX_Logos_ManifestId_Kind_Source\" ON \"Logos\" (\"ManifestId\", \"Kind\", \"Source\");\n\nCREATE INDEX \"IX_EncryptionKeys_ManifestId_IsPrimary\" ON \"EncryptionKeys\" (\"ManifestId\", \"IsPrimary\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260809201530_2.1.0-ManifestScopedStorage', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TRIGGER IF NOT EXISTS \"TR_Items_ResyncChildManifestIds\"\nAFTER UPDATE OF \"ManifestId\" ON \"Items\"\nFOR EACH ROW WHEN OLD.\"ManifestId\" <> NEW.\"ManifestId\"\nBEGIN\n UPDATE \"FieldValues\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"FieldHistories\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"ItemTags\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"Attachments\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"Passkeys\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"TotpCodes\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"ItemStats\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"Id\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\nEND;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260809201914_2.1.1-ItemChildManifestTrigger', '10.0.10');\n\nCOMMIT;\n";
+declare const COMPLETE_SCHEMA_SQL = "\n\uFEFFCREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\n \"MigrationId\" TEXT NOT NULL CONSTRAINT \"PK___EFMigrationsHistory\" PRIMARY KEY,\n \"ProductVersion\" TEXT NOT NULL\n);\n\nBEGIN TRANSACTION;\nCREATE TABLE \"Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"Gender\" VARCHAR NULL,\n \"FirstName\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"BirthDate\" TEXT NOT NULL,\n \"AddressStreet\" VARCHAR NULL,\n \"AddressCity\" VARCHAR NULL,\n \"AddressState\" VARCHAR NULL,\n \"AddressZipCode\" VARCHAR NULL,\n \"AddressCountry\" VARCHAR NULL,\n \"Hobbies\" TEXT NULL,\n \"EmailPrefix\" TEXT NULL,\n \"PhoneMobile\" TEXT NULL,\n \"BankAccountIBAN\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Services\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Services\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"Url\" TEXT NULL,\n \"Logo\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"Username\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"ServiceId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Attachment\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachment\" PRIMARY KEY,\n \"Filename\" TEXT NOT NULL,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachment_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Passwords\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passwords\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Passwords_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_Attachment_CredentialId\" ON \"Attachment\" (\"CredentialId\");\n\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\n\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\n\nCREATE INDEX \"IX_Passwords_CredentialId\" ON \"Passwords\" (\"CredentialId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240708094944_1.0.0-InitialMigration', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240708224522_1.0.1-EmptyTestMigration', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nALTER TABLE \"Aliases\" RENAME COLUMN \"EmailPrefix\" TO \"Email\";\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240711204207_1.0.2-ChangeEmailColumn', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"EncryptionKeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240729105618_1.1.0-AddPkiTables', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"Settings\" (\n \"Key\" TEXT NOT NULL CONSTRAINT \"PK_Settings\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240805073413_1.2.0-AddSettingsTable', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"BirthDate\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Email\" TEXT NULL,\n \"FirstName\" VARCHAR NULL,\n \"Gender\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"ef_temp_Aliases\" (\"Id\", \"BirthDate\", \"CreatedAt\", \"Email\", \"FirstName\", \"Gender\", \"LastName\", \"NickName\", \"UpdatedAt\")\nSELECT \"Id\", \"BirthDate\", \"CreatedAt\", \"Email\", \"FirstName\", \"Gender\", \"LastName\", \"NickName\", \"UpdatedAt\"\nFROM \"Aliases\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Aliases\";\n\nALTER TABLE \"ef_temp_Aliases\" RENAME TO \"Aliases\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240805122422_1.3.0-UpdateIdentityStructure', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"ServiceId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Username\" TEXT NULL,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Credentials\" (\"Id\", \"AliasId\", \"CreatedAt\", \"Notes\", \"ServiceId\", \"UpdatedAt\", \"Username\")\nSELECT \"Id\", \"AliasId\", \"CreatedAt\", \"Notes\", \"ServiceId\", \"UpdatedAt\", \"Username\"\nFROM \"Credentials\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Credentials\";\n\nALTER TABLE \"ef_temp_Credentials\" RENAME TO \"Credentials\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\n\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240812141727_1.3.1-MakeUsernameOptional', '10.0.10');\n\nBEGIN TRANSACTION;\nALTER TABLE \"Settings\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Services\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Passwords\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"EncryptionKeys\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Credentials\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Attachment\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Aliases\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240916105320_1.4.0-AddSyncSupport', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nALTER TABLE \"Attachment\" RENAME TO \"Attachments\";\n\nCREATE TABLE \"ef_temp_Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"Id\", \"Blob\", \"CreatedAt\", \"CredentialId\", \"Filename\", \"IsDeleted\", \"UpdatedAt\")\nSELECT \"Id\", \"Blob\", \"CreatedAt\", \"CredentialId\", \"Filename\", \"IsDeleted\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_CredentialId\" ON \"Attachments\" (\"CredentialId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240917191243_1.4.1-RenameAttachmentsPlural', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TABLE \"TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_TotpCodes_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_TotpCodes_CredentialId\" ON \"TotpCodes\" (\"CredentialId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20250310131554_1.5.0-AddTotpCodes', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\n\nPRAGMA foreign_keys = OFF;\n\n-- Clean up any existing temp tables first\nDROP TABLE IF EXISTS \"__EFMigrationsHistory_temp\";\nDROP TABLE IF EXISTS \"Aliases_temp\";\nDROP TABLE IF EXISTS \"Services_temp\";\nDROP TABLE IF EXISTS \"EncryptionKeys_temp\";\nDROP TABLE IF EXISTS \"Settings_temp\";\nDROP TABLE IF EXISTS \"Credentials_temp\";\nDROP TABLE IF EXISTS \"Attachments_temp\";\nDROP TABLE IF EXISTS \"Passwords_temp\";\nDROP TABLE IF EXISTS \"TotpCodes_temp\";\n\n-- Create backup tables for all data\nCREATE TABLE \"__EFMigrationsHistory_temp\" AS SELECT * FROM \"__EFMigrationsHistory\";\nCREATE TABLE \"Aliases_temp\" AS SELECT * FROM \"Aliases\";\nCREATE TABLE \"Services_temp\" AS SELECT * FROM \"Services\";\nCREATE TABLE \"EncryptionKeys_temp\" AS SELECT * FROM \"EncryptionKeys\";\nCREATE TABLE \"Settings_temp\" AS SELECT * FROM \"Settings\";\nCREATE TABLE \"Credentials_temp\" AS SELECT * FROM \"Credentials\";\nCREATE TABLE \"Attachments_temp\" AS SELECT * FROM \"Attachments\";\nCREATE TABLE \"Passwords_temp\" AS SELECT * FROM \"Passwords\";\nCREATE TABLE \"TotpCodes_temp\" AS SELECT * FROM \"TotpCodes\";\n\n-- Delete orphaned records that do not have a valid FK to the credential object\nDELETE FROM \"Attachments_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"Passwords_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"TotpCodes_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\n\n-- Delete orphaned credentials that do not have valid FKs to alias or service objects\nDELETE FROM \"Credentials_temp\" WHERE \"AliasId\" NOT IN (SELECT \"Id\" FROM \"Aliases_temp\");\nDELETE FROM \"Credentials_temp\" WHERE \"ServiceId\" NOT IN (SELECT \"Id\" FROM \"Services_temp\");\n\n-- After cleaning credentials, clean dependent tables again in case we removed credentials\nDELETE FROM \"Attachments_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"Passwords_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"TotpCodes_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\n\n-- Drop all existing tables\nDROP TABLE \"TotpCodes\";\nDROP TABLE \"Passwords\";\nDROP TABLE \"Attachments\";\nDROP TABLE \"Credentials\";\nDROP TABLE \"Settings\";\nDROP TABLE \"EncryptionKeys\";\nDROP TABLE \"Services\";\nDROP TABLE \"Aliases\";\nDROP TABLE \"__EFMigrationsHistory\";\n\n-- Recreate tables with proper constraints (no dependencies first)\nCREATE TABLE \"__EFMigrationsHistory\" (\n \"MigrationId\" TEXT NOT NULL CONSTRAINT \"PK___EFMigrationsHistory\" PRIMARY KEY,\n \"ProductVersion\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"BirthDate\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Email\" TEXT NULL,\n \"FirstName\" VARCHAR NULL,\n \"Gender\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"Services\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Services\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"Url\" TEXT NULL,\n \"Logo\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"EncryptionKeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"Settings\" (\n \"Key\" TEXT NOT NULL CONSTRAINT \"PK_Settings\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\n-- Tables with foreign keys\nCREATE TABLE \"Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"ServiceId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Username\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Passwords\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passwords\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_Passwords_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_TotpCodes_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\n\n-- Restore data from temp tables\nINSERT INTO \"__EFMigrationsHistory\" SELECT * FROM \"__EFMigrationsHistory_temp\";\nINSERT INTO \"Aliases\" SELECT * FROM \"Aliases_temp\";\nINSERT INTO \"Services\" SELECT * FROM \"Services_temp\";\nINSERT INTO \"EncryptionKeys\" SELECT * FROM \"EncryptionKeys_temp\";\nINSERT INTO \"Settings\" SELECT * FROM \"Settings_temp\";\nINSERT INTO \"Credentials\" SELECT * FROM \"Credentials_temp\";\nINSERT INTO \"Attachments\" SELECT * FROM \"Attachments_temp\";\nINSERT INTO \"Passwords\" SELECT * FROM \"Passwords_temp\";\nINSERT INTO \"TotpCodes\" SELECT * FROM \"TotpCodes_temp\";\n\n-- =====================================================================================\n-- Date Format Normalization Migration\n-- =====================================================================================\n-- This migration normalizes ALL date fields to the standard format: 'yyyy-MM-dd HH:mm:ss.fff'\n-- Previously the different clients used different date formats which complicate date parsing.\n-- From version 0.24.0 onwards, all new dates are stored in this standard format.\n\n-- Update Aliases table (CreatedAt, UpdatedAt, BirthDate)\nUPDATE \"Aliases\" SET \"CreatedAt\" =\n CASE\n -- Already in correct format (yyyy-MM-dd HH:mm:ss.fff) - no change\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n\n -- ISO 8601 with milliseconds (yyyy-MM-ddTHH:mm:ss.fffZ) -> Replace T with space, remove Z and everything after .fff\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n\n -- Without milliseconds (yyyy-MM-dd HH:mm:ss or yyyy-MM-ddTHH:mm:ssZ) -> Add .000\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n\n -- Fallback: if none match, keep as-is (edge case)\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Aliases\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- BirthDate: Always set time to 00:00:00 (no milliseconds for birth dates)\nUPDATE \"Aliases\" SET \"BirthDate\" =\n CASE\n -- If empty or already '0001-01-01 00:00:00', keep as-is\n WHEN \"BirthDate\" = '' OR \"BirthDate\" = '0001-01-01 00:00:00'\n THEN \"BirthDate\"\n\n -- If already in correct format (yyyy-MM-dd 00:00:00), keep as-is\n WHEN \"BirthDate\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] 00:00:00'\n THEN \"BirthDate\"\n\n -- Extract date part and set time to 00:00:00\n WHEN \"BirthDate\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*'\n THEN substr(\"BirthDate\", 1, 10) || ' 00:00:00'\n\n -- Fallback\n ELSE \"BirthDate\"\n END;\n\n-- Update Services table (CreatedAt, UpdatedAt)\nUPDATE \"Services\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Services\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update EncryptionKeys table (CreatedAt, UpdatedAt)\nUPDATE \"EncryptionKeys\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"EncryptionKeys\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Settings table (CreatedAt, UpdatedAt)\nUPDATE \"Settings\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Settings\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Credentials table (CreatedAt, UpdatedAt)\nUPDATE \"Credentials\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Credentials\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Attachments table (CreatedAt, UpdatedAt)\nUPDATE \"Attachments\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Attachments\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Passwords table (CreatedAt, UpdatedAt)\nUPDATE \"Passwords\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Passwords\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update TotpCodes table (CreatedAt, UpdatedAt)\nUPDATE \"TotpCodes\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"TotpCodes\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- =====================================================================================\n-- End of Date Format Normalization Migration\n-- =====================================================================================\n\n-- Recreate indexes\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\nCREATE INDEX \"IX_Attachments_CredentialId\" ON \"Attachments\" (\"CredentialId\");\nCREATE INDEX \"IX_Passwords_CredentialId\" ON \"Passwords\" (\"CredentialId\");\nCREATE INDEX \"IX_TotpCodes_CredentialId\" ON \"TotpCodes\" (\"CredentialId\");\n\n-- Clean up temp tables\nDROP TABLE \"__EFMigrationsHistory_temp\";\nDROP TABLE \"Aliases_temp\";\nDROP TABLE \"Services_temp\";\nDROP TABLE \"EncryptionKeys_temp\";\nDROP TABLE \"Settings_temp\";\nDROP TABLE \"Credentials_temp\";\nDROP TABLE \"Attachments_temp\";\nDROP TABLE \"Passwords_temp\";\nDROP TABLE \"TotpCodes_temp\";\n\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"Passkeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passkeys\" PRIMARY KEY,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"AdditionalData\" BLOB NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Passkeys_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_Passkeys_CredentialId\" ON \"Passkeys\" (\"CredentialId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20251014122838_1.6.0-AddPasskeys', '10.0.10');\n\nCOMMIT;\n\nPRAGMA foreign_keys = OFF;\n\nBEGIN TRANSACTION;\nALTER TABLE \"TotpCodes\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_TotpCodes_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_TotpCodes_ItemId\" ON \"TotpCodes\" (\"ItemId\");\n\nALTER TABLE \"Passkeys\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_Passkeys_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_Passkeys_ItemId\" ON \"Passkeys\" (\"ItemId\");\n\nALTER TABLE \"Attachments\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_Attachments_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_Attachments_ItemId\" ON \"Attachments\" (\"ItemId\");\n\nCREATE TABLE \"FieldDefinitions\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldDefinitions\" PRIMARY KEY,\n \"FieldType\" TEXT NOT NULL,\n \"Label\" TEXT NOT NULL,\n \"IsMultiValue\" INTEGER NOT NULL,\n \"IsHidden\" INTEGER NOT NULL,\n \"EnableHistory\" INTEGER NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"ApplicableToTypes\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Folders\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Folders\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"ParentFolderId\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Folders_Folders_ParentFolderId\" FOREIGN KEY (\"ParentFolderId\") REFERENCES \"Folders\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Logos\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Logos\" PRIMARY KEY,\n \"Source\" TEXT NOT NULL,\n \"FileData\" BLOB NULL,\n \"MimeType\" TEXT NULL,\n \"FetchedAt\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Tags\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Tags\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"Color\" TEXT NULL,\n \"DisplayOrder\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Items\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Items\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"ItemType\" TEXT NOT NULL,\n \"LogoId\" TEXT NULL,\n \"DeletedAt\" TEXT NULL,\n \"FolderId\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Items_Folders_FolderId\" FOREIGN KEY (\"FolderId\") REFERENCES \"Folders\" (\"Id\") ON DELETE SET NULL,\n CONSTRAINT \"FK_Items_Logos_LogoId\" FOREIGN KEY (\"LogoId\") REFERENCES \"Logos\" (\"Id\") ON DELETE SET NULL\n);\n\nCREATE TABLE \"FieldHistories\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldHistories\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"ValueSnapshot\" TEXT NOT NULL,\n \"ChangedAt\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_FieldHistories_FieldDefinitions_FieldDefinitionId\" FOREIGN KEY (\"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldHistories_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"FieldValues\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldValues\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"Value\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_FieldValues_FieldDefinitions_FieldDefinitionId\" FOREIGN KEY (\"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldValues_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"ItemTags\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_ItemTags\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"TagId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_ItemTags_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_ItemTags_Tags_TagId\" FOREIGN KEY (\"TagId\") REFERENCES \"Tags\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_FieldHistories_FieldDefinitionId\" ON \"FieldHistories\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ItemId\" ON \"FieldHistories\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_FieldDefinitionId\" ON \"FieldValues\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_FieldKey\" ON \"FieldValues\" (\"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ItemId\" ON \"FieldValues\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldDefinitionId_Weight\" ON \"FieldValues\" (\"ItemId\", \"FieldDefinitionId\", \"Weight\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldKey\" ON \"FieldValues\" (\"ItemId\", \"FieldKey\");\n\nCREATE INDEX \"IX_Folders_ParentFolderId\" ON \"Folders\" (\"ParentFolderId\");\n\nCREATE INDEX \"IX_Items_FolderId\" ON \"Items\" (\"FolderId\");\n\nCREATE INDEX \"IX_Items_LogoId\" ON \"Items\" (\"LogoId\");\n\nCREATE INDEX \"IX_ItemTags_ItemId\" ON \"ItemTags\" (\"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ItemId_TagId\" ON \"ItemTags\" (\"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_TagId\" ON \"ItemTags\" (\"TagId\");\n\nCREATE UNIQUE INDEX \"IX_Logos_Source\" ON \"Logos\" (\"Source\");\n\nCREATE INDEX \"IX_Tags_Name\" ON \"Tags\" (\"Name\");\n\n\n INSERT INTO Items (Id, Name, ItemType, LogoId, FolderId, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n c.Id,\n s.Name AS Name,\n CASE\n WHEN a.Id IS NOT NULL AND (\n (a.FirstName IS NOT NULL AND a.FirstName != '') OR\n (a.LastName IS NOT NULL AND a.LastName != '') OR\n (a.Gender IS NOT NULL AND a.Gender != '') OR\n (a.BirthDate IS NOT NULL AND a.BirthDate != '' AND a.BirthDate NOT LIKE '0001-%')\n ) THEN 'Alias'\n ELSE 'Login'\n END AS ItemType,\n NULL AS LogoId,\n NULL AS FolderId,\n c.CreatedAt,\n c.UpdatedAt,\n c.IsDeleted\n FROM Credentials c\n LEFT JOIN Services s ON s.Id = c.ServiceId\n LEFT JOIN Aliases a ON a.Id = c.AliasId;\n \n\n\n INSERT INTO Logos (Id, Source, FileData, MimeType, FetchedAt, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n -- Extract and normalize hostname: remove protocol, path, lowercase, and www. prefix\n REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n ) AS Source,\n s.Logo AS FileData,\n 'image/png' AS MimeType,\n NULL AS FetchedAt,\n MIN(s.CreatedAt) AS CreatedAt,\n MAX(s.UpdatedAt) AS UpdatedAt,\n 0 AS IsDeleted\n FROM Services s\n WHERE s.Logo IS NOT NULL AND s.Url IS NOT NULL AND s.Url != ''\n GROUP BY REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n );\n \n\n\n UPDATE Items\n SET LogoId = (\n SELECT l.Id FROM Logos l\n INNER JOIN Services s ON REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n ) = l.Source\n INNER JOIN Credentials c ON c.ServiceId = s.Id\n WHERE c.Id = Items.Id\n LIMIT 1\n )\n WHERE EXISTS (\n SELECT 1 FROM Credentials c\n INNER JOIN Services s ON s.Id = c.ServiceId\n WHERE c.Id = Items.Id AND s.Logo IS NOT NULL\n );\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.url' AS FieldKey,\n s.Url AS Value,\n 0 AS Weight,\n s.UpdatedAt AS CreatedAt,\n s.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Services s ON s.Id = c.ServiceId\n WHERE s.Url IS NOT NULL AND s.Url != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.username' AS FieldKey,\n c.Username AS Value,\n 0 AS Weight,\n c.UpdatedAt AS CreatedAt,\n c.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n WHERE c.Username IS NOT NULL AND c.Username != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'notes.content' AS FieldKey,\n c.Notes AS Value,\n 0 AS Weight,\n c.UpdatedAt AS CreatedAt,\n c.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n WHERE c.Notes IS NOT NULL AND c.Notes != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n p.CredentialId AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.password' AS FieldKey,\n p.Value AS Value,\n 0 AS Weight,\n p.UpdatedAt AS CreatedAt,\n p.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Passwords p\n INNER JOIN (\n SELECT CredentialId, MAX(UpdatedAt) AS MaxUpdated, MAX(Id) AS MaxId\n FROM Passwords\n WHERE IsDeleted = 0\n GROUP BY CredentialId\n ) pm ON p.CredentialId = pm.CredentialId AND p.UpdatedAt = pm.MaxUpdated AND p.Id = pm.MaxId\n WHERE p.IsDeleted = 0;\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.email' AS FieldKey,\n a.Email AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.Email IS NOT NULL AND a.Email != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.first_name' AS FieldKey,\n a.FirstName AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.FirstName IS NOT NULL AND a.FirstName != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.last_name' AS FieldKey,\n a.LastName AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.LastName IS NOT NULL AND a.LastName != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.gender' AS FieldKey,\n a.Gender AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.Gender IS NOT NULL AND a.Gender != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.birthdate' AS FieldKey,\n SUBSTR(a.BirthDate, 1, 10) AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.BirthDate IS NOT NULL AND a.BirthDate != '' AND a.BirthDate NOT LIKE '0001-%';\n \n\nDROP TABLE \"Passwords\";\n\nDROP TABLE \"Credentials\";\n\nDROP TABLE \"Aliases\";\n\nDROP TABLE \"Services\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = ON;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\")\nSELECT \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCREATE TABLE \"ef_temp_Passkeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passkeys\" PRIMARY KEY,\n \"AdditionalData\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n CONSTRAINT \"FK_Passkeys_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Passkeys\" (\"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\")\nSELECT \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\"\nFROM \"Passkeys\";\n\nCREATE TABLE \"ef_temp_TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_TotpCodes_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_TotpCodes\" (\"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\")\nSELECT \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\"\nFROM \"TotpCodes\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nDROP TABLE \"Passkeys\";\n\nALTER TABLE \"ef_temp_Passkeys\" RENAME TO \"Passkeys\";\n\nDROP TABLE \"TotpCodes\";\n\nALTER TABLE \"ef_temp_TotpCodes\" RENAME TO \"TotpCodes\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_ItemId\" ON \"Attachments\" (\"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_ItemId\" ON \"Passkeys\" (\"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nCREATE INDEX \"IX_TotpCodes_ItemId\" ON \"TotpCodes\" (\"ItemId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20251213111207_1.7.0-FieldBasedDataModelUpdate', '10.0.10');\n\nBEGIN TRANSACTION;\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260130221620_2.0.0-MajorVersionBump', '10.0.10');\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP INDEX \"IX_TotpCodes_ItemId\";\n\nDROP INDEX \"IX_Tags_Name\";\n\nDROP INDEX \"IX_Passkeys_ItemId\";\n\nDROP INDEX \"IX_Logos_Source\";\n\nDROP INDEX \"IX_ItemTags_ItemId_TagId\";\n\nDROP INDEX \"IX_Items_FolderId\";\n\nDROP INDEX \"IX_Items_LogoId\";\n\nDROP INDEX \"IX_Attachments_ItemId\";\n\nALTER TABLE \"TotpCodes\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Tags\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Settings\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Passkeys\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Logos\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Logos\" ADD \"Kind\" TEXT NOT NULL DEFAULT 'favicon';\n\nALTER TABLE \"Logos\" ADD \"Name\" TEXT NULL;\n\nALTER TABLE \"ItemTags\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Items\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Folders\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldValues\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldHistories\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldDefinitions\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"EncryptionKeys\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Attachments\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nCREATE TABLE \"CodecOverflows\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_CodecOverflows\" PRIMARY KEY,\n \"Data\" TEXT NOT NULL\n);\n\nCREATE TABLE \"ItemStats\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"LastUsedAt\" TEXT NULL,\n \"UseCount\" INTEGER NOT NULL,\n \"LastAutofilledAt\" TEXT NULL,\n \"AutofillCount\" INTEGER NOT NULL,\n \"LastCopiedAt\" TEXT NULL,\n \"CopyCount\" INTEGER NOT NULL,\n \"LastPasskeyAuthAt\" TEXT NULL,\n \"PasskeyAuthCount\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"PK_ItemStats\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nCREATE TABLE \"Manifests\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Manifests\" PRIMARY KEY,\n \"Name\" TEXT NULL\n);\n\nCREATE INDEX \"IX_TotpCodes_ManifestId_ItemId\" ON \"TotpCodes\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Tags_ManifestId_Name\" ON \"Tags\" (\"ManifestId\", \"Name\");\n\nCREATE INDEX \"IX_Passkeys_ManifestId_ItemId\" ON \"Passkeys\" (\"ManifestId\", \"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_Logos_ManifestId_Kind_Source\" ON \"Logos\" (\"ManifestId\", \"Kind\", \"Source\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ManifestId_ItemId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_ManifestId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"TagId\");\n\nCREATE INDEX \"IX_Items_ManifestId_FolderId\" ON \"Items\" (\"ManifestId\", \"FolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_LogoId\" ON \"Items\" (\"ManifestId\", \"LogoId\");\n\nCREATE INDEX \"IX_Folders_ManifestId_ParentFolderId\" ON \"Folders\" (\"ManifestId\", \"ParentFolderId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_FieldDefinitionId\" ON \"FieldValues\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_ItemId\" ON \"FieldValues\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_FieldDefinitionId\" ON \"FieldHistories\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_ItemId\" ON \"FieldHistories\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_EncryptionKeys_ManifestId_IsPrimary\" ON \"EncryptionKeys\" (\"ManifestId\", \"IsPrimary\");\n\nCREATE INDEX \"IX_Attachments_ManifestId_ItemId\" ON \"Attachments\" (\"ManifestId\", \"ItemId\");\n\nCREATE TABLE \"ef_temp_Attachments\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Attachments\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Attachments_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"ManifestId\", \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCREATE TABLE \"ef_temp_FieldHistories\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"ChangedAt\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"ValueSnapshot\" TEXT NOT NULL,\n CONSTRAINT \"PK_FieldHistories\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_FieldHistories_FieldDefinitions_ManifestId_FieldDefinitionId\" FOREIGN KEY (\"ManifestId\", \"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldHistories_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_FieldHistories\" (\"ManifestId\", \"Id\", \"ChangedAt\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"ValueSnapshot\")\nSELECT \"ManifestId\", \"Id\", \"ChangedAt\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"ValueSnapshot\"\nFROM \"FieldHistories\";\n\nCREATE TABLE \"ef_temp_FieldValues\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Value\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_FieldValues\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_FieldValues_FieldDefinitions_ManifestId_FieldDefinitionId\" FOREIGN KEY (\"ManifestId\", \"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldValues_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_FieldValues\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"Value\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"Value\", \"Weight\"\nFROM \"FieldValues\";\n\nCREATE TABLE \"ef_temp_Folders\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"ParentFolderId\" TEXT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_Folders\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Folders_Folders_ManifestId_ParentFolderId\" FOREIGN KEY (\"ManifestId\", \"ParentFolderId\") REFERENCES \"Folders\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Folders\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"Name\", \"ParentFolderId\", \"UpdatedAt\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"Name\", \"ParentFolderId\", \"UpdatedAt\", \"Weight\"\nFROM \"Folders\";\n\nCREATE TABLE \"ef_temp_Items\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DeletedAt\" TEXT NULL,\n \"FolderId\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemType\" TEXT NOT NULL,\n \"LogoId\" TEXT NULL,\n \"Name\" TEXT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Items\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Items_Folders_ManifestId_FolderId\" FOREIGN KEY (\"ManifestId\", \"FolderId\") REFERENCES \"Folders\" (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Items_Logos_ManifestId_LogoId\" FOREIGN KEY (\"ManifestId\", \"LogoId\") REFERENCES \"Logos\" (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Items\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"DeletedAt\", \"FolderId\", \"IsDeleted\", \"ItemType\", \"LogoId\", \"Name\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"DeletedAt\", \"FolderId\", \"IsDeleted\", \"ItemType\", \"LogoId\", \"Name\", \"UpdatedAt\"\nFROM \"Items\";\n\nCREATE TABLE \"ef_temp_ItemTags\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"TagId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_ItemTags\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_ItemTags_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_ItemTags_Tags_ManifestId_TagId\" FOREIGN KEY (\"ManifestId\", \"TagId\") REFERENCES \"Tags\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_ItemTags\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"TagId\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"TagId\", \"UpdatedAt\"\nFROM \"ItemTags\";\n\nCREATE TABLE \"ef_temp_Passkeys\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"AdditionalData\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n CONSTRAINT \"PK_Passkeys\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Passkeys_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Passkeys\" (\"ManifestId\", \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\")\nSELECT \"ManifestId\", \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\"\nFROM \"Passkeys\";\n\nCREATE TABLE \"ef_temp_TotpCodes\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_TotpCodes_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_TotpCodes\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\"\nFROM \"TotpCodes\";\n\nCREATE TABLE \"ef_temp_Tags\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"Color\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayOrder\" INTEGER NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Tags\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Tags\" (\"ManifestId\", \"Id\", \"Color\", \"CreatedAt\", \"DisplayOrder\", \"IsDeleted\", \"Name\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"Color\", \"CreatedAt\", \"DisplayOrder\", \"IsDeleted\", \"Name\", \"UpdatedAt\"\nFROM \"Tags\";\n\nCREATE TABLE \"ef_temp_Settings\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Key\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Value\" TEXT NULL,\n CONSTRAINT \"PK_Settings\" PRIMARY KEY (\"ManifestId\", \"Key\")\n);\n\nINSERT INTO \"ef_temp_Settings\" (\"ManifestId\", \"Key\", \"CreatedAt\", \"IsDeleted\", \"UpdatedAt\", \"Value\")\nSELECT \"ManifestId\", \"Key\", \"CreatedAt\", \"IsDeleted\", \"UpdatedAt\", \"Value\"\nFROM \"Settings\";\n\nCREATE TABLE \"ef_temp_Logos\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FetchedAt\" TEXT NULL,\n \"FileData\" BLOB NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Kind\" TEXT NOT NULL DEFAULT 'favicon',\n \"MimeType\" TEXT NULL,\n \"Name\" TEXT NULL,\n \"Source\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Logos\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Logos\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"FetchedAt\", \"FileData\", \"IsDeleted\", \"Kind\", \"MimeType\", \"Name\", \"Source\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"FetchedAt\", \"FileData\", \"IsDeleted\", \"Kind\", \"MimeType\", \"Name\", \"Source\", \"UpdatedAt\"\nFROM \"Logos\";\n\nCREATE TABLE \"ef_temp_FieldDefinitions\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"ApplicableToTypes\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"EnableHistory\" INTEGER NOT NULL,\n \"FieldType\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"IsHidden\" INTEGER NOT NULL,\n \"IsMultiValue\" INTEGER NOT NULL,\n \"Label\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_FieldDefinitions\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_FieldDefinitions\" (\"ManifestId\", \"Id\", \"ApplicableToTypes\", \"CreatedAt\", \"EnableHistory\", \"FieldType\", \"IsDeleted\", \"IsHidden\", \"IsMultiValue\", \"Label\", \"UpdatedAt\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"ApplicableToTypes\", \"CreatedAt\", \"EnableHistory\", \"FieldType\", \"IsDeleted\", \"IsHidden\", \"IsMultiValue\", \"Label\", \"UpdatedAt\", \"Weight\"\nFROM \"FieldDefinitions\";\n\nCREATE TABLE \"ef_temp_EncryptionKeys\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_EncryptionKeys\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"IsPrimary\", \"PrivateKey\", \"PublicKey\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"IsPrimary\", \"PrivateKey\", \"PublicKey\", \"UpdatedAt\"\nFROM \"EncryptionKeys\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nDROP TABLE \"FieldHistories\";\n\nALTER TABLE \"ef_temp_FieldHistories\" RENAME TO \"FieldHistories\";\n\nDROP TABLE \"FieldValues\";\n\nALTER TABLE \"ef_temp_FieldValues\" RENAME TO \"FieldValues\";\n\nDROP TABLE \"Folders\";\n\nALTER TABLE \"ef_temp_Folders\" RENAME TO \"Folders\";\n\nDROP TABLE \"Items\";\n\nALTER TABLE \"ef_temp_Items\" RENAME TO \"Items\";\n\nDROP TABLE \"ItemTags\";\n\nALTER TABLE \"ef_temp_ItemTags\" RENAME TO \"ItemTags\";\n\nDROP TABLE \"Passkeys\";\n\nALTER TABLE \"ef_temp_Passkeys\" RENAME TO \"Passkeys\";\n\nDROP TABLE \"TotpCodes\";\n\nALTER TABLE \"ef_temp_TotpCodes\" RENAME TO \"TotpCodes\";\n\nDROP TABLE \"Tags\";\n\nALTER TABLE \"ef_temp_Tags\" RENAME TO \"Tags\";\n\nDROP TABLE \"Settings\";\n\nALTER TABLE \"ef_temp_Settings\" RENAME TO \"Settings\";\n\nDROP TABLE \"Logos\";\n\nALTER TABLE \"ef_temp_Logos\" RENAME TO \"Logos\";\n\nDROP TABLE \"FieldDefinitions\";\n\nALTER TABLE \"ef_temp_FieldDefinitions\" RENAME TO \"FieldDefinitions\";\n\nDROP TABLE \"EncryptionKeys\";\n\nALTER TABLE \"ef_temp_EncryptionKeys\" RENAME TO \"EncryptionKeys\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_ManifestId_ItemId\" ON \"Attachments\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_FieldDefinitionId\" ON \"FieldHistories\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ItemId\" ON \"FieldHistories\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_FieldDefinitionId\" ON \"FieldHistories\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_ItemId\" ON \"FieldHistories\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_FieldDefinitionId\" ON \"FieldValues\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_FieldKey\" ON \"FieldValues\" (\"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ItemId\" ON \"FieldValues\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldDefinitionId_Weight\" ON \"FieldValues\" (\"ItemId\", \"FieldDefinitionId\", \"Weight\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldKey\" ON \"FieldValues\" (\"ItemId\", \"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_FieldDefinitionId\" ON \"FieldValues\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_ItemId\" ON \"FieldValues\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Folders_ManifestId_ParentFolderId\" ON \"Folders\" (\"ManifestId\", \"ParentFolderId\");\n\nCREATE INDEX \"IX_Folders_ParentFolderId\" ON \"Folders\" (\"ParentFolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_FolderId\" ON \"Items\" (\"ManifestId\", \"FolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_LogoId\" ON \"Items\" (\"ManifestId\", \"LogoId\");\n\nCREATE INDEX \"IX_ItemTags_ItemId\" ON \"ItemTags\" (\"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ManifestId_ItemId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_ManifestId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_TagId\" ON \"ItemTags\" (\"TagId\");\n\nCREATE INDEX \"IX_Passkeys_ManifestId_ItemId\" ON \"Passkeys\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nCREATE INDEX \"IX_TotpCodes_ManifestId_ItemId\" ON \"TotpCodes\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Tags_ManifestId_Name\" ON \"Tags\" (\"ManifestId\", \"Name\");\n\nCREATE UNIQUE INDEX \"IX_Logos_ManifestId_Kind_Source\" ON \"Logos\" (\"ManifestId\", \"Kind\", \"Source\");\n\nCREATE INDEX \"IX_EncryptionKeys_ManifestId_IsPrimary\" ON \"EncryptionKeys\" (\"ManifestId\", \"IsPrimary\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260809201530_2.1.0-ManifestScopedStorage', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TRIGGER IF NOT EXISTS \"TR_Items_ResyncChildManifestIds\"\nAFTER UPDATE OF \"ManifestId\" ON \"Items\"\nFOR EACH ROW WHEN OLD.\"ManifestId\" <> NEW.\"ManifestId\"\nBEGIN\n UPDATE \"FieldValues\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"FieldHistories\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"ItemTags\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"Attachments\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"Passkeys\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"TotpCodes\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"ItemStats\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"Id\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\nEND;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260809201914_2.1.1-ItemChildManifestTrigger', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nALTER TABLE \"TotpCodes\" ADD \"Algorithm\" TEXT NOT NULL DEFAULT 'SHA1';\n\nALTER TABLE \"TotpCodes\" ADD \"Digits\" INTEGER NOT NULL DEFAULT 6;\n\nALTER TABLE \"TotpCodes\" ADD \"Period\" INTEGER NOT NULL DEFAULT 30;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260810093834_2.1.2-AddTotpParameters', '10.0.10');\n\nCOMMIT;\n";
/**
* Individual migration SQL scripts
* Auto-generated from EF Core migrations
diff --git a/apps/browser-extension/src/utils/dist/core/vault/index.d.ts b/apps/browser-extension/src/utils/dist/core/vault/index.d.ts
index 0d24f5c11..041fd6580 100644
--- a/apps/browser-extension/src/utils/dist/core/vault/index.d.ts
+++ b/apps/browser-extension/src/utils/dist/core/vault/index.d.ts
@@ -128,7 +128,7 @@ declare const VAULT_VERSIONS: VaultVersion[];
* Complete database schema SQL (latest version)
* Auto-generated from EF Core migrations
*/
-declare const COMPLETE_SCHEMA_SQL = "\n\uFEFFCREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\n \"MigrationId\" TEXT NOT NULL CONSTRAINT \"PK___EFMigrationsHistory\" PRIMARY KEY,\n \"ProductVersion\" TEXT NOT NULL\n);\n\nBEGIN TRANSACTION;\nCREATE TABLE \"Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"Gender\" VARCHAR NULL,\n \"FirstName\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"BirthDate\" TEXT NOT NULL,\n \"AddressStreet\" VARCHAR NULL,\n \"AddressCity\" VARCHAR NULL,\n \"AddressState\" VARCHAR NULL,\n \"AddressZipCode\" VARCHAR NULL,\n \"AddressCountry\" VARCHAR NULL,\n \"Hobbies\" TEXT NULL,\n \"EmailPrefix\" TEXT NULL,\n \"PhoneMobile\" TEXT NULL,\n \"BankAccountIBAN\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Services\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Services\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"Url\" TEXT NULL,\n \"Logo\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"Username\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"ServiceId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Attachment\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachment\" PRIMARY KEY,\n \"Filename\" TEXT NOT NULL,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachment_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Passwords\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passwords\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Passwords_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_Attachment_CredentialId\" ON \"Attachment\" (\"CredentialId\");\n\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\n\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\n\nCREATE INDEX \"IX_Passwords_CredentialId\" ON \"Passwords\" (\"CredentialId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240708094944_1.0.0-InitialMigration', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240708224522_1.0.1-EmptyTestMigration', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nALTER TABLE \"Aliases\" RENAME COLUMN \"EmailPrefix\" TO \"Email\";\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240711204207_1.0.2-ChangeEmailColumn', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"EncryptionKeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240729105618_1.1.0-AddPkiTables', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"Settings\" (\n \"Key\" TEXT NOT NULL CONSTRAINT \"PK_Settings\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240805073413_1.2.0-AddSettingsTable', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"BirthDate\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Email\" TEXT NULL,\n \"FirstName\" VARCHAR NULL,\n \"Gender\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"ef_temp_Aliases\" (\"Id\", \"BirthDate\", \"CreatedAt\", \"Email\", \"FirstName\", \"Gender\", \"LastName\", \"NickName\", \"UpdatedAt\")\nSELECT \"Id\", \"BirthDate\", \"CreatedAt\", \"Email\", \"FirstName\", \"Gender\", \"LastName\", \"NickName\", \"UpdatedAt\"\nFROM \"Aliases\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Aliases\";\n\nALTER TABLE \"ef_temp_Aliases\" RENAME TO \"Aliases\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240805122422_1.3.0-UpdateIdentityStructure', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"ServiceId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Username\" TEXT NULL,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Credentials\" (\"Id\", \"AliasId\", \"CreatedAt\", \"Notes\", \"ServiceId\", \"UpdatedAt\", \"Username\")\nSELECT \"Id\", \"AliasId\", \"CreatedAt\", \"Notes\", \"ServiceId\", \"UpdatedAt\", \"Username\"\nFROM \"Credentials\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Credentials\";\n\nALTER TABLE \"ef_temp_Credentials\" RENAME TO \"Credentials\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\n\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240812141727_1.3.1-MakeUsernameOptional', '10.0.10');\n\nBEGIN TRANSACTION;\nALTER TABLE \"Settings\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Services\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Passwords\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"EncryptionKeys\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Credentials\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Attachment\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Aliases\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240916105320_1.4.0-AddSyncSupport', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nALTER TABLE \"Attachment\" RENAME TO \"Attachments\";\n\nCREATE TABLE \"ef_temp_Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"Id\", \"Blob\", \"CreatedAt\", \"CredentialId\", \"Filename\", \"IsDeleted\", \"UpdatedAt\")\nSELECT \"Id\", \"Blob\", \"CreatedAt\", \"CredentialId\", \"Filename\", \"IsDeleted\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_CredentialId\" ON \"Attachments\" (\"CredentialId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240917191243_1.4.1-RenameAttachmentsPlural', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TABLE \"TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_TotpCodes_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_TotpCodes_CredentialId\" ON \"TotpCodes\" (\"CredentialId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20250310131554_1.5.0-AddTotpCodes', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\n\nPRAGMA foreign_keys = OFF;\n\n-- Clean up any existing temp tables first\nDROP TABLE IF EXISTS \"__EFMigrationsHistory_temp\";\nDROP TABLE IF EXISTS \"Aliases_temp\";\nDROP TABLE IF EXISTS \"Services_temp\";\nDROP TABLE IF EXISTS \"EncryptionKeys_temp\";\nDROP TABLE IF EXISTS \"Settings_temp\";\nDROP TABLE IF EXISTS \"Credentials_temp\";\nDROP TABLE IF EXISTS \"Attachments_temp\";\nDROP TABLE IF EXISTS \"Passwords_temp\";\nDROP TABLE IF EXISTS \"TotpCodes_temp\";\n\n-- Create backup tables for all data\nCREATE TABLE \"__EFMigrationsHistory_temp\" AS SELECT * FROM \"__EFMigrationsHistory\";\nCREATE TABLE \"Aliases_temp\" AS SELECT * FROM \"Aliases\";\nCREATE TABLE \"Services_temp\" AS SELECT * FROM \"Services\";\nCREATE TABLE \"EncryptionKeys_temp\" AS SELECT * FROM \"EncryptionKeys\";\nCREATE TABLE \"Settings_temp\" AS SELECT * FROM \"Settings\";\nCREATE TABLE \"Credentials_temp\" AS SELECT * FROM \"Credentials\";\nCREATE TABLE \"Attachments_temp\" AS SELECT * FROM \"Attachments\";\nCREATE TABLE \"Passwords_temp\" AS SELECT * FROM \"Passwords\";\nCREATE TABLE \"TotpCodes_temp\" AS SELECT * FROM \"TotpCodes\";\n\n-- Delete orphaned records that do not have a valid FK to the credential object\nDELETE FROM \"Attachments_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"Passwords_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"TotpCodes_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\n\n-- Delete orphaned credentials that do not have valid FKs to alias or service objects\nDELETE FROM \"Credentials_temp\" WHERE \"AliasId\" NOT IN (SELECT \"Id\" FROM \"Aliases_temp\");\nDELETE FROM \"Credentials_temp\" WHERE \"ServiceId\" NOT IN (SELECT \"Id\" FROM \"Services_temp\");\n\n-- After cleaning credentials, clean dependent tables again in case we removed credentials\nDELETE FROM \"Attachments_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"Passwords_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"TotpCodes_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\n\n-- Drop all existing tables\nDROP TABLE \"TotpCodes\";\nDROP TABLE \"Passwords\";\nDROP TABLE \"Attachments\";\nDROP TABLE \"Credentials\";\nDROP TABLE \"Settings\";\nDROP TABLE \"EncryptionKeys\";\nDROP TABLE \"Services\";\nDROP TABLE \"Aliases\";\nDROP TABLE \"__EFMigrationsHistory\";\n\n-- Recreate tables with proper constraints (no dependencies first)\nCREATE TABLE \"__EFMigrationsHistory\" (\n \"MigrationId\" TEXT NOT NULL CONSTRAINT \"PK___EFMigrationsHistory\" PRIMARY KEY,\n \"ProductVersion\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"BirthDate\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Email\" TEXT NULL,\n \"FirstName\" VARCHAR NULL,\n \"Gender\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"Services\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Services\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"Url\" TEXT NULL,\n \"Logo\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"EncryptionKeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"Settings\" (\n \"Key\" TEXT NOT NULL CONSTRAINT \"PK_Settings\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\n-- Tables with foreign keys\nCREATE TABLE \"Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"ServiceId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Username\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Passwords\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passwords\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_Passwords_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_TotpCodes_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\n\n-- Restore data from temp tables\nINSERT INTO \"__EFMigrationsHistory\" SELECT * FROM \"__EFMigrationsHistory_temp\";\nINSERT INTO \"Aliases\" SELECT * FROM \"Aliases_temp\";\nINSERT INTO \"Services\" SELECT * FROM \"Services_temp\";\nINSERT INTO \"EncryptionKeys\" SELECT * FROM \"EncryptionKeys_temp\";\nINSERT INTO \"Settings\" SELECT * FROM \"Settings_temp\";\nINSERT INTO \"Credentials\" SELECT * FROM \"Credentials_temp\";\nINSERT INTO \"Attachments\" SELECT * FROM \"Attachments_temp\";\nINSERT INTO \"Passwords\" SELECT * FROM \"Passwords_temp\";\nINSERT INTO \"TotpCodes\" SELECT * FROM \"TotpCodes_temp\";\n\n-- =====================================================================================\n-- Date Format Normalization Migration\n-- =====================================================================================\n-- This migration normalizes ALL date fields to the standard format: 'yyyy-MM-dd HH:mm:ss.fff'\n-- Previously the different clients used different date formats which complicate date parsing.\n-- From version 0.24.0 onwards, all new dates are stored in this standard format.\n\n-- Update Aliases table (CreatedAt, UpdatedAt, BirthDate)\nUPDATE \"Aliases\" SET \"CreatedAt\" =\n CASE\n -- Already in correct format (yyyy-MM-dd HH:mm:ss.fff) - no change\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n\n -- ISO 8601 with milliseconds (yyyy-MM-ddTHH:mm:ss.fffZ) -> Replace T with space, remove Z and everything after .fff\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n\n -- Without milliseconds (yyyy-MM-dd HH:mm:ss or yyyy-MM-ddTHH:mm:ssZ) -> Add .000\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n\n -- Fallback: if none match, keep as-is (edge case)\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Aliases\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- BirthDate: Always set time to 00:00:00 (no milliseconds for birth dates)\nUPDATE \"Aliases\" SET \"BirthDate\" =\n CASE\n -- If empty or already '0001-01-01 00:00:00', keep as-is\n WHEN \"BirthDate\" = '' OR \"BirthDate\" = '0001-01-01 00:00:00'\n THEN \"BirthDate\"\n\n -- If already in correct format (yyyy-MM-dd 00:00:00), keep as-is\n WHEN \"BirthDate\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] 00:00:00'\n THEN \"BirthDate\"\n\n -- Extract date part and set time to 00:00:00\n WHEN \"BirthDate\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*'\n THEN substr(\"BirthDate\", 1, 10) || ' 00:00:00'\n\n -- Fallback\n ELSE \"BirthDate\"\n END;\n\n-- Update Services table (CreatedAt, UpdatedAt)\nUPDATE \"Services\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Services\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update EncryptionKeys table (CreatedAt, UpdatedAt)\nUPDATE \"EncryptionKeys\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"EncryptionKeys\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Settings table (CreatedAt, UpdatedAt)\nUPDATE \"Settings\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Settings\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Credentials table (CreatedAt, UpdatedAt)\nUPDATE \"Credentials\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Credentials\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Attachments table (CreatedAt, UpdatedAt)\nUPDATE \"Attachments\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Attachments\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Passwords table (CreatedAt, UpdatedAt)\nUPDATE \"Passwords\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Passwords\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update TotpCodes table (CreatedAt, UpdatedAt)\nUPDATE \"TotpCodes\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"TotpCodes\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- =====================================================================================\n-- End of Date Format Normalization Migration\n-- =====================================================================================\n\n-- Recreate indexes\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\nCREATE INDEX \"IX_Attachments_CredentialId\" ON \"Attachments\" (\"CredentialId\");\nCREATE INDEX \"IX_Passwords_CredentialId\" ON \"Passwords\" (\"CredentialId\");\nCREATE INDEX \"IX_TotpCodes_CredentialId\" ON \"TotpCodes\" (\"CredentialId\");\n\n-- Clean up temp tables\nDROP TABLE \"__EFMigrationsHistory_temp\";\nDROP TABLE \"Aliases_temp\";\nDROP TABLE \"Services_temp\";\nDROP TABLE \"EncryptionKeys_temp\";\nDROP TABLE \"Settings_temp\";\nDROP TABLE \"Credentials_temp\";\nDROP TABLE \"Attachments_temp\";\nDROP TABLE \"Passwords_temp\";\nDROP TABLE \"TotpCodes_temp\";\n\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"Passkeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passkeys\" PRIMARY KEY,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"AdditionalData\" BLOB NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Passkeys_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_Passkeys_CredentialId\" ON \"Passkeys\" (\"CredentialId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20251014122838_1.6.0-AddPasskeys', '10.0.10');\n\nCOMMIT;\n\nPRAGMA foreign_keys = OFF;\n\nBEGIN TRANSACTION;\nALTER TABLE \"TotpCodes\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_TotpCodes_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_TotpCodes_ItemId\" ON \"TotpCodes\" (\"ItemId\");\n\nALTER TABLE \"Passkeys\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_Passkeys_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_Passkeys_ItemId\" ON \"Passkeys\" (\"ItemId\");\n\nALTER TABLE \"Attachments\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_Attachments_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_Attachments_ItemId\" ON \"Attachments\" (\"ItemId\");\n\nCREATE TABLE \"FieldDefinitions\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldDefinitions\" PRIMARY KEY,\n \"FieldType\" TEXT NOT NULL,\n \"Label\" TEXT NOT NULL,\n \"IsMultiValue\" INTEGER NOT NULL,\n \"IsHidden\" INTEGER NOT NULL,\n \"EnableHistory\" INTEGER NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"ApplicableToTypes\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Folders\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Folders\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"ParentFolderId\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Folders_Folders_ParentFolderId\" FOREIGN KEY (\"ParentFolderId\") REFERENCES \"Folders\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Logos\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Logos\" PRIMARY KEY,\n \"Source\" TEXT NOT NULL,\n \"FileData\" BLOB NULL,\n \"MimeType\" TEXT NULL,\n \"FetchedAt\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Tags\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Tags\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"Color\" TEXT NULL,\n \"DisplayOrder\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Items\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Items\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"ItemType\" TEXT NOT NULL,\n \"LogoId\" TEXT NULL,\n \"DeletedAt\" TEXT NULL,\n \"FolderId\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Items_Folders_FolderId\" FOREIGN KEY (\"FolderId\") REFERENCES \"Folders\" (\"Id\") ON DELETE SET NULL,\n CONSTRAINT \"FK_Items_Logos_LogoId\" FOREIGN KEY (\"LogoId\") REFERENCES \"Logos\" (\"Id\") ON DELETE SET NULL\n);\n\nCREATE TABLE \"FieldHistories\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldHistories\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"ValueSnapshot\" TEXT NOT NULL,\n \"ChangedAt\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_FieldHistories_FieldDefinitions_FieldDefinitionId\" FOREIGN KEY (\"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldHistories_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"FieldValues\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldValues\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"Value\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_FieldValues_FieldDefinitions_FieldDefinitionId\" FOREIGN KEY (\"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldValues_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"ItemTags\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_ItemTags\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"TagId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_ItemTags_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_ItemTags_Tags_TagId\" FOREIGN KEY (\"TagId\") REFERENCES \"Tags\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_FieldHistories_FieldDefinitionId\" ON \"FieldHistories\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ItemId\" ON \"FieldHistories\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_FieldDefinitionId\" ON \"FieldValues\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_FieldKey\" ON \"FieldValues\" (\"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ItemId\" ON \"FieldValues\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldDefinitionId_Weight\" ON \"FieldValues\" (\"ItemId\", \"FieldDefinitionId\", \"Weight\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldKey\" ON \"FieldValues\" (\"ItemId\", \"FieldKey\");\n\nCREATE INDEX \"IX_Folders_ParentFolderId\" ON \"Folders\" (\"ParentFolderId\");\n\nCREATE INDEX \"IX_Items_FolderId\" ON \"Items\" (\"FolderId\");\n\nCREATE INDEX \"IX_Items_LogoId\" ON \"Items\" (\"LogoId\");\n\nCREATE INDEX \"IX_ItemTags_ItemId\" ON \"ItemTags\" (\"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ItemId_TagId\" ON \"ItemTags\" (\"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_TagId\" ON \"ItemTags\" (\"TagId\");\n\nCREATE UNIQUE INDEX \"IX_Logos_Source\" ON \"Logos\" (\"Source\");\n\nCREATE INDEX \"IX_Tags_Name\" ON \"Tags\" (\"Name\");\n\n\n INSERT INTO Items (Id, Name, ItemType, LogoId, FolderId, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n c.Id,\n s.Name AS Name,\n CASE\n WHEN a.Id IS NOT NULL AND (\n (a.FirstName IS NOT NULL AND a.FirstName != '') OR\n (a.LastName IS NOT NULL AND a.LastName != '') OR\n (a.Gender IS NOT NULL AND a.Gender != '') OR\n (a.BirthDate IS NOT NULL AND a.BirthDate != '' AND a.BirthDate NOT LIKE '0001-%')\n ) THEN 'Alias'\n ELSE 'Login'\n END AS ItemType,\n NULL AS LogoId,\n NULL AS FolderId,\n c.CreatedAt,\n c.UpdatedAt,\n c.IsDeleted\n FROM Credentials c\n LEFT JOIN Services s ON s.Id = c.ServiceId\n LEFT JOIN Aliases a ON a.Id = c.AliasId;\n \n\n\n INSERT INTO Logos (Id, Source, FileData, MimeType, FetchedAt, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n -- Extract and normalize hostname: remove protocol, path, lowercase, and www. prefix\n REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n ) AS Source,\n s.Logo AS FileData,\n 'image/png' AS MimeType,\n NULL AS FetchedAt,\n MIN(s.CreatedAt) AS CreatedAt,\n MAX(s.UpdatedAt) AS UpdatedAt,\n 0 AS IsDeleted\n FROM Services s\n WHERE s.Logo IS NOT NULL AND s.Url IS NOT NULL AND s.Url != ''\n GROUP BY REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n );\n \n\n\n UPDATE Items\n SET LogoId = (\n SELECT l.Id FROM Logos l\n INNER JOIN Services s ON REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n ) = l.Source\n INNER JOIN Credentials c ON c.ServiceId = s.Id\n WHERE c.Id = Items.Id\n LIMIT 1\n )\n WHERE EXISTS (\n SELECT 1 FROM Credentials c\n INNER JOIN Services s ON s.Id = c.ServiceId\n WHERE c.Id = Items.Id AND s.Logo IS NOT NULL\n );\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.url' AS FieldKey,\n s.Url AS Value,\n 0 AS Weight,\n s.UpdatedAt AS CreatedAt,\n s.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Services s ON s.Id = c.ServiceId\n WHERE s.Url IS NOT NULL AND s.Url != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.username' AS FieldKey,\n c.Username AS Value,\n 0 AS Weight,\n c.UpdatedAt AS CreatedAt,\n c.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n WHERE c.Username IS NOT NULL AND c.Username != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'notes.content' AS FieldKey,\n c.Notes AS Value,\n 0 AS Weight,\n c.UpdatedAt AS CreatedAt,\n c.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n WHERE c.Notes IS NOT NULL AND c.Notes != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n p.CredentialId AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.password' AS FieldKey,\n p.Value AS Value,\n 0 AS Weight,\n p.UpdatedAt AS CreatedAt,\n p.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Passwords p\n INNER JOIN (\n SELECT CredentialId, MAX(UpdatedAt) AS MaxUpdated, MAX(Id) AS MaxId\n FROM Passwords\n WHERE IsDeleted = 0\n GROUP BY CredentialId\n ) pm ON p.CredentialId = pm.CredentialId AND p.UpdatedAt = pm.MaxUpdated AND p.Id = pm.MaxId\n WHERE p.IsDeleted = 0;\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.email' AS FieldKey,\n a.Email AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.Email IS NOT NULL AND a.Email != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.first_name' AS FieldKey,\n a.FirstName AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.FirstName IS NOT NULL AND a.FirstName != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.last_name' AS FieldKey,\n a.LastName AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.LastName IS NOT NULL AND a.LastName != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.gender' AS FieldKey,\n a.Gender AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.Gender IS NOT NULL AND a.Gender != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.birthdate' AS FieldKey,\n SUBSTR(a.BirthDate, 1, 10) AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.BirthDate IS NOT NULL AND a.BirthDate != '' AND a.BirthDate NOT LIKE '0001-%';\n \n\nDROP TABLE \"Passwords\";\n\nDROP TABLE \"Credentials\";\n\nDROP TABLE \"Aliases\";\n\nDROP TABLE \"Services\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = ON;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\")\nSELECT \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCREATE TABLE \"ef_temp_Passkeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passkeys\" PRIMARY KEY,\n \"AdditionalData\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n CONSTRAINT \"FK_Passkeys_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Passkeys\" (\"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\")\nSELECT \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\"\nFROM \"Passkeys\";\n\nCREATE TABLE \"ef_temp_TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_TotpCodes_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_TotpCodes\" (\"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\")\nSELECT \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\"\nFROM \"TotpCodes\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nDROP TABLE \"Passkeys\";\n\nALTER TABLE \"ef_temp_Passkeys\" RENAME TO \"Passkeys\";\n\nDROP TABLE \"TotpCodes\";\n\nALTER TABLE \"ef_temp_TotpCodes\" RENAME TO \"TotpCodes\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_ItemId\" ON \"Attachments\" (\"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_ItemId\" ON \"Passkeys\" (\"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nCREATE INDEX \"IX_TotpCodes_ItemId\" ON \"TotpCodes\" (\"ItemId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20251213111207_1.7.0-FieldBasedDataModelUpdate', '10.0.10');\n\nBEGIN TRANSACTION;\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260130221620_2.0.0-MajorVersionBump', '10.0.10');\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP INDEX \"IX_TotpCodes_ItemId\";\n\nDROP INDEX \"IX_Tags_Name\";\n\nDROP INDEX \"IX_Passkeys_ItemId\";\n\nDROP INDEX \"IX_Logos_Source\";\n\nDROP INDEX \"IX_ItemTags_ItemId_TagId\";\n\nDROP INDEX \"IX_Items_FolderId\";\n\nDROP INDEX \"IX_Items_LogoId\";\n\nDROP INDEX \"IX_Attachments_ItemId\";\n\nALTER TABLE \"TotpCodes\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Tags\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Settings\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Passkeys\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Logos\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Logos\" ADD \"Kind\" TEXT NOT NULL DEFAULT 'favicon';\n\nALTER TABLE \"Logos\" ADD \"Name\" TEXT NULL;\n\nALTER TABLE \"ItemTags\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Items\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Folders\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldValues\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldHistories\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldDefinitions\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"EncryptionKeys\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Attachments\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nCREATE TABLE \"CodecOverflows\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_CodecOverflows\" PRIMARY KEY,\n \"Data\" TEXT NOT NULL\n);\n\nCREATE TABLE \"ItemStats\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"LastUsedAt\" TEXT NULL,\n \"UseCount\" INTEGER NOT NULL,\n \"LastAutofilledAt\" TEXT NULL,\n \"AutofillCount\" INTEGER NOT NULL,\n \"LastCopiedAt\" TEXT NULL,\n \"CopyCount\" INTEGER NOT NULL,\n \"LastPasskeyAuthAt\" TEXT NULL,\n \"PasskeyAuthCount\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"PK_ItemStats\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nCREATE TABLE \"Manifests\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Manifests\" PRIMARY KEY,\n \"Name\" TEXT NULL\n);\n\nCREATE INDEX \"IX_TotpCodes_ManifestId_ItemId\" ON \"TotpCodes\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Tags_ManifestId_Name\" ON \"Tags\" (\"ManifestId\", \"Name\");\n\nCREATE INDEX \"IX_Passkeys_ManifestId_ItemId\" ON \"Passkeys\" (\"ManifestId\", \"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_Logos_ManifestId_Kind_Source\" ON \"Logos\" (\"ManifestId\", \"Kind\", \"Source\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ManifestId_ItemId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_ManifestId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"TagId\");\n\nCREATE INDEX \"IX_Items_ManifestId_FolderId\" ON \"Items\" (\"ManifestId\", \"FolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_LogoId\" ON \"Items\" (\"ManifestId\", \"LogoId\");\n\nCREATE INDEX \"IX_Folders_ManifestId_ParentFolderId\" ON \"Folders\" (\"ManifestId\", \"ParentFolderId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_FieldDefinitionId\" ON \"FieldValues\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_ItemId\" ON \"FieldValues\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_FieldDefinitionId\" ON \"FieldHistories\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_ItemId\" ON \"FieldHistories\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_EncryptionKeys_ManifestId_IsPrimary\" ON \"EncryptionKeys\" (\"ManifestId\", \"IsPrimary\");\n\nCREATE INDEX \"IX_Attachments_ManifestId_ItemId\" ON \"Attachments\" (\"ManifestId\", \"ItemId\");\n\nCREATE TABLE \"ef_temp_Attachments\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Attachments\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Attachments_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"ManifestId\", \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCREATE TABLE \"ef_temp_FieldHistories\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"ChangedAt\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"ValueSnapshot\" TEXT NOT NULL,\n CONSTRAINT \"PK_FieldHistories\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_FieldHistories_FieldDefinitions_ManifestId_FieldDefinitionId\" FOREIGN KEY (\"ManifestId\", \"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldHistories_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_FieldHistories\" (\"ManifestId\", \"Id\", \"ChangedAt\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"ValueSnapshot\")\nSELECT \"ManifestId\", \"Id\", \"ChangedAt\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"ValueSnapshot\"\nFROM \"FieldHistories\";\n\nCREATE TABLE \"ef_temp_FieldValues\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Value\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_FieldValues\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_FieldValues_FieldDefinitions_ManifestId_FieldDefinitionId\" FOREIGN KEY (\"ManifestId\", \"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldValues_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_FieldValues\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"Value\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"Value\", \"Weight\"\nFROM \"FieldValues\";\n\nCREATE TABLE \"ef_temp_Folders\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"ParentFolderId\" TEXT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_Folders\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Folders_Folders_ManifestId_ParentFolderId\" FOREIGN KEY (\"ManifestId\", \"ParentFolderId\") REFERENCES \"Folders\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Folders\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"Name\", \"ParentFolderId\", \"UpdatedAt\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"Name\", \"ParentFolderId\", \"UpdatedAt\", \"Weight\"\nFROM \"Folders\";\n\nCREATE TABLE \"ef_temp_Items\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DeletedAt\" TEXT NULL,\n \"FolderId\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemType\" TEXT NOT NULL,\n \"LogoId\" TEXT NULL,\n \"Name\" TEXT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Items\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Items_Folders_ManifestId_FolderId\" FOREIGN KEY (\"ManifestId\", \"FolderId\") REFERENCES \"Folders\" (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Items_Logos_ManifestId_LogoId\" FOREIGN KEY (\"ManifestId\", \"LogoId\") REFERENCES \"Logos\" (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Items\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"DeletedAt\", \"FolderId\", \"IsDeleted\", \"ItemType\", \"LogoId\", \"Name\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"DeletedAt\", \"FolderId\", \"IsDeleted\", \"ItemType\", \"LogoId\", \"Name\", \"UpdatedAt\"\nFROM \"Items\";\n\nCREATE TABLE \"ef_temp_ItemTags\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"TagId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_ItemTags\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_ItemTags_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_ItemTags_Tags_ManifestId_TagId\" FOREIGN KEY (\"ManifestId\", \"TagId\") REFERENCES \"Tags\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_ItemTags\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"TagId\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"TagId\", \"UpdatedAt\"\nFROM \"ItemTags\";\n\nCREATE TABLE \"ef_temp_Passkeys\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"AdditionalData\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n CONSTRAINT \"PK_Passkeys\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Passkeys_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Passkeys\" (\"ManifestId\", \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\")\nSELECT \"ManifestId\", \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\"\nFROM \"Passkeys\";\n\nCREATE TABLE \"ef_temp_TotpCodes\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_TotpCodes_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_TotpCodes\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\"\nFROM \"TotpCodes\";\n\nCREATE TABLE \"ef_temp_Tags\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"Color\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayOrder\" INTEGER NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Tags\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Tags\" (\"ManifestId\", \"Id\", \"Color\", \"CreatedAt\", \"DisplayOrder\", \"IsDeleted\", \"Name\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"Color\", \"CreatedAt\", \"DisplayOrder\", \"IsDeleted\", \"Name\", \"UpdatedAt\"\nFROM \"Tags\";\n\nCREATE TABLE \"ef_temp_Settings\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Key\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Value\" TEXT NULL,\n CONSTRAINT \"PK_Settings\" PRIMARY KEY (\"ManifestId\", \"Key\")\n);\n\nINSERT INTO \"ef_temp_Settings\" (\"ManifestId\", \"Key\", \"CreatedAt\", \"IsDeleted\", \"UpdatedAt\", \"Value\")\nSELECT \"ManifestId\", \"Key\", \"CreatedAt\", \"IsDeleted\", \"UpdatedAt\", \"Value\"\nFROM \"Settings\";\n\nCREATE TABLE \"ef_temp_Logos\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FetchedAt\" TEXT NULL,\n \"FileData\" BLOB NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Kind\" TEXT NOT NULL DEFAULT 'favicon',\n \"MimeType\" TEXT NULL,\n \"Name\" TEXT NULL,\n \"Source\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Logos\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Logos\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"FetchedAt\", \"FileData\", \"IsDeleted\", \"Kind\", \"MimeType\", \"Name\", \"Source\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"FetchedAt\", \"FileData\", \"IsDeleted\", \"Kind\", \"MimeType\", \"Name\", \"Source\", \"UpdatedAt\"\nFROM \"Logos\";\n\nCREATE TABLE \"ef_temp_FieldDefinitions\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"ApplicableToTypes\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"EnableHistory\" INTEGER NOT NULL,\n \"FieldType\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"IsHidden\" INTEGER NOT NULL,\n \"IsMultiValue\" INTEGER NOT NULL,\n \"Label\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_FieldDefinitions\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_FieldDefinitions\" (\"ManifestId\", \"Id\", \"ApplicableToTypes\", \"CreatedAt\", \"EnableHistory\", \"FieldType\", \"IsDeleted\", \"IsHidden\", \"IsMultiValue\", \"Label\", \"UpdatedAt\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"ApplicableToTypes\", \"CreatedAt\", \"EnableHistory\", \"FieldType\", \"IsDeleted\", \"IsHidden\", \"IsMultiValue\", \"Label\", \"UpdatedAt\", \"Weight\"\nFROM \"FieldDefinitions\";\n\nCREATE TABLE \"ef_temp_EncryptionKeys\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_EncryptionKeys\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"IsPrimary\", \"PrivateKey\", \"PublicKey\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"IsPrimary\", \"PrivateKey\", \"PublicKey\", \"UpdatedAt\"\nFROM \"EncryptionKeys\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nDROP TABLE \"FieldHistories\";\n\nALTER TABLE \"ef_temp_FieldHistories\" RENAME TO \"FieldHistories\";\n\nDROP TABLE \"FieldValues\";\n\nALTER TABLE \"ef_temp_FieldValues\" RENAME TO \"FieldValues\";\n\nDROP TABLE \"Folders\";\n\nALTER TABLE \"ef_temp_Folders\" RENAME TO \"Folders\";\n\nDROP TABLE \"Items\";\n\nALTER TABLE \"ef_temp_Items\" RENAME TO \"Items\";\n\nDROP TABLE \"ItemTags\";\n\nALTER TABLE \"ef_temp_ItemTags\" RENAME TO \"ItemTags\";\n\nDROP TABLE \"Passkeys\";\n\nALTER TABLE \"ef_temp_Passkeys\" RENAME TO \"Passkeys\";\n\nDROP TABLE \"TotpCodes\";\n\nALTER TABLE \"ef_temp_TotpCodes\" RENAME TO \"TotpCodes\";\n\nDROP TABLE \"Tags\";\n\nALTER TABLE \"ef_temp_Tags\" RENAME TO \"Tags\";\n\nDROP TABLE \"Settings\";\n\nALTER TABLE \"ef_temp_Settings\" RENAME TO \"Settings\";\n\nDROP TABLE \"Logos\";\n\nALTER TABLE \"ef_temp_Logos\" RENAME TO \"Logos\";\n\nDROP TABLE \"FieldDefinitions\";\n\nALTER TABLE \"ef_temp_FieldDefinitions\" RENAME TO \"FieldDefinitions\";\n\nDROP TABLE \"EncryptionKeys\";\n\nALTER TABLE \"ef_temp_EncryptionKeys\" RENAME TO \"EncryptionKeys\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_ManifestId_ItemId\" ON \"Attachments\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_FieldDefinitionId\" ON \"FieldHistories\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ItemId\" ON \"FieldHistories\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_FieldDefinitionId\" ON \"FieldHistories\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_ItemId\" ON \"FieldHistories\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_FieldDefinitionId\" ON \"FieldValues\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_FieldKey\" ON \"FieldValues\" (\"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ItemId\" ON \"FieldValues\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldDefinitionId_Weight\" ON \"FieldValues\" (\"ItemId\", \"FieldDefinitionId\", \"Weight\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldKey\" ON \"FieldValues\" (\"ItemId\", \"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_FieldDefinitionId\" ON \"FieldValues\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_ItemId\" ON \"FieldValues\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Folders_ManifestId_ParentFolderId\" ON \"Folders\" (\"ManifestId\", \"ParentFolderId\");\n\nCREATE INDEX \"IX_Folders_ParentFolderId\" ON \"Folders\" (\"ParentFolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_FolderId\" ON \"Items\" (\"ManifestId\", \"FolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_LogoId\" ON \"Items\" (\"ManifestId\", \"LogoId\");\n\nCREATE INDEX \"IX_ItemTags_ItemId\" ON \"ItemTags\" (\"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ManifestId_ItemId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_ManifestId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_TagId\" ON \"ItemTags\" (\"TagId\");\n\nCREATE INDEX \"IX_Passkeys_ManifestId_ItemId\" ON \"Passkeys\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nCREATE INDEX \"IX_TotpCodes_ManifestId_ItemId\" ON \"TotpCodes\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Tags_ManifestId_Name\" ON \"Tags\" (\"ManifestId\", \"Name\");\n\nCREATE UNIQUE INDEX \"IX_Logos_ManifestId_Kind_Source\" ON \"Logos\" (\"ManifestId\", \"Kind\", \"Source\");\n\nCREATE INDEX \"IX_EncryptionKeys_ManifestId_IsPrimary\" ON \"EncryptionKeys\" (\"ManifestId\", \"IsPrimary\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260809201530_2.1.0-ManifestScopedStorage', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TRIGGER IF NOT EXISTS \"TR_Items_ResyncChildManifestIds\"\nAFTER UPDATE OF \"ManifestId\" ON \"Items\"\nFOR EACH ROW WHEN OLD.\"ManifestId\" <> NEW.\"ManifestId\"\nBEGIN\n UPDATE \"FieldValues\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"FieldHistories\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"ItemTags\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"Attachments\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"Passkeys\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"TotpCodes\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"ItemStats\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"Id\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\nEND;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260809201914_2.1.1-ItemChildManifestTrigger', '10.0.10');\n\nCOMMIT;\n";
+declare const COMPLETE_SCHEMA_SQL = "\n\uFEFFCREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\n \"MigrationId\" TEXT NOT NULL CONSTRAINT \"PK___EFMigrationsHistory\" PRIMARY KEY,\n \"ProductVersion\" TEXT NOT NULL\n);\n\nBEGIN TRANSACTION;\nCREATE TABLE \"Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"Gender\" VARCHAR NULL,\n \"FirstName\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"BirthDate\" TEXT NOT NULL,\n \"AddressStreet\" VARCHAR NULL,\n \"AddressCity\" VARCHAR NULL,\n \"AddressState\" VARCHAR NULL,\n \"AddressZipCode\" VARCHAR NULL,\n \"AddressCountry\" VARCHAR NULL,\n \"Hobbies\" TEXT NULL,\n \"EmailPrefix\" TEXT NULL,\n \"PhoneMobile\" TEXT NULL,\n \"BankAccountIBAN\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Services\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Services\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"Url\" TEXT NULL,\n \"Logo\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"Username\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"ServiceId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Attachment\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachment\" PRIMARY KEY,\n \"Filename\" TEXT NOT NULL,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachment_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Passwords\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passwords\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n CONSTRAINT \"FK_Passwords_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_Attachment_CredentialId\" ON \"Attachment\" (\"CredentialId\");\n\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\n\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\n\nCREATE INDEX \"IX_Passwords_CredentialId\" ON \"Passwords\" (\"CredentialId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240708094944_1.0.0-InitialMigration', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240708224522_1.0.1-EmptyTestMigration', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nALTER TABLE \"Aliases\" RENAME COLUMN \"EmailPrefix\" TO \"Email\";\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240711204207_1.0.2-ChangeEmailColumn', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"EncryptionKeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240729105618_1.1.0-AddPkiTables', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"Settings\" (\n \"Key\" TEXT NOT NULL CONSTRAINT \"PK_Settings\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240805073413_1.2.0-AddSettingsTable', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"BirthDate\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Email\" TEXT NULL,\n \"FirstName\" VARCHAR NULL,\n \"Gender\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"UpdatedAt\" TEXT NOT NULL\n);\n\nINSERT INTO \"ef_temp_Aliases\" (\"Id\", \"BirthDate\", \"CreatedAt\", \"Email\", \"FirstName\", \"Gender\", \"LastName\", \"NickName\", \"UpdatedAt\")\nSELECT \"Id\", \"BirthDate\", \"CreatedAt\", \"Email\", \"FirstName\", \"Gender\", \"LastName\", \"NickName\", \"UpdatedAt\"\nFROM \"Aliases\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Aliases\";\n\nALTER TABLE \"ef_temp_Aliases\" RENAME TO \"Aliases\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240805122422_1.3.0-UpdateIdentityStructure', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"ServiceId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Username\" TEXT NULL,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Credentials\" (\"Id\", \"AliasId\", \"CreatedAt\", \"Notes\", \"ServiceId\", \"UpdatedAt\", \"Username\")\nSELECT \"Id\", \"AliasId\", \"CreatedAt\", \"Notes\", \"ServiceId\", \"UpdatedAt\", \"Username\"\nFROM \"Credentials\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Credentials\";\n\nALTER TABLE \"ef_temp_Credentials\" RENAME TO \"Credentials\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\n\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240812141727_1.3.1-MakeUsernameOptional', '10.0.10');\n\nBEGIN TRANSACTION;\nALTER TABLE \"Settings\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Services\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Passwords\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"EncryptionKeys\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Credentials\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Attachment\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nALTER TABLE \"Aliases\" ADD \"IsDeleted\" INTEGER NOT NULL DEFAULT 0;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240916105320_1.4.0-AddSyncSupport', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nALTER TABLE \"Attachment\" RENAME TO \"Attachments\";\n\nCREATE TABLE \"ef_temp_Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"Id\", \"Blob\", \"CreatedAt\", \"CredentialId\", \"Filename\", \"IsDeleted\", \"UpdatedAt\")\nSELECT \"Id\", \"Blob\", \"CreatedAt\", \"CredentialId\", \"Filename\", \"IsDeleted\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_CredentialId\" ON \"Attachments\" (\"CredentialId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20240917191243_1.4.1-RenameAttachmentsPlural', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TABLE \"TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_TotpCodes_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_TotpCodes_CredentialId\" ON \"TotpCodes\" (\"CredentialId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20250310131554_1.5.0-AddTotpCodes', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\n\nPRAGMA foreign_keys = OFF;\n\n-- Clean up any existing temp tables first\nDROP TABLE IF EXISTS \"__EFMigrationsHistory_temp\";\nDROP TABLE IF EXISTS \"Aliases_temp\";\nDROP TABLE IF EXISTS \"Services_temp\";\nDROP TABLE IF EXISTS \"EncryptionKeys_temp\";\nDROP TABLE IF EXISTS \"Settings_temp\";\nDROP TABLE IF EXISTS \"Credentials_temp\";\nDROP TABLE IF EXISTS \"Attachments_temp\";\nDROP TABLE IF EXISTS \"Passwords_temp\";\nDROP TABLE IF EXISTS \"TotpCodes_temp\";\n\n-- Create backup tables for all data\nCREATE TABLE \"__EFMigrationsHistory_temp\" AS SELECT * FROM \"__EFMigrationsHistory\";\nCREATE TABLE \"Aliases_temp\" AS SELECT * FROM \"Aliases\";\nCREATE TABLE \"Services_temp\" AS SELECT * FROM \"Services\";\nCREATE TABLE \"EncryptionKeys_temp\" AS SELECT * FROM \"EncryptionKeys\";\nCREATE TABLE \"Settings_temp\" AS SELECT * FROM \"Settings\";\nCREATE TABLE \"Credentials_temp\" AS SELECT * FROM \"Credentials\";\nCREATE TABLE \"Attachments_temp\" AS SELECT * FROM \"Attachments\";\nCREATE TABLE \"Passwords_temp\" AS SELECT * FROM \"Passwords\";\nCREATE TABLE \"TotpCodes_temp\" AS SELECT * FROM \"TotpCodes\";\n\n-- Delete orphaned records that do not have a valid FK to the credential object\nDELETE FROM \"Attachments_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"Passwords_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"TotpCodes_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\n\n-- Delete orphaned credentials that do not have valid FKs to alias or service objects\nDELETE FROM \"Credentials_temp\" WHERE \"AliasId\" NOT IN (SELECT \"Id\" FROM \"Aliases_temp\");\nDELETE FROM \"Credentials_temp\" WHERE \"ServiceId\" NOT IN (SELECT \"Id\" FROM \"Services_temp\");\n\n-- After cleaning credentials, clean dependent tables again in case we removed credentials\nDELETE FROM \"Attachments_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"Passwords_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\nDELETE FROM \"TotpCodes_temp\" WHERE \"CredentialId\" NOT IN (SELECT \"Id\" FROM \"Credentials_temp\");\n\n-- Drop all existing tables\nDROP TABLE \"TotpCodes\";\nDROP TABLE \"Passwords\";\nDROP TABLE \"Attachments\";\nDROP TABLE \"Credentials\";\nDROP TABLE \"Settings\";\nDROP TABLE \"EncryptionKeys\";\nDROP TABLE \"Services\";\nDROP TABLE \"Aliases\";\nDROP TABLE \"__EFMigrationsHistory\";\n\n-- Recreate tables with proper constraints (no dependencies first)\nCREATE TABLE \"__EFMigrationsHistory\" (\n \"MigrationId\" TEXT NOT NULL CONSTRAINT \"PK___EFMigrationsHistory\" PRIMARY KEY,\n \"ProductVersion\" TEXT NOT NULL\n);\n\nCREATE TABLE \"Aliases\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Aliases\" PRIMARY KEY,\n \"BirthDate\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Email\" TEXT NULL,\n \"FirstName\" VARCHAR NULL,\n \"Gender\" VARCHAR NULL,\n \"LastName\" VARCHAR NULL,\n \"NickName\" VARCHAR NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"Services\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Services\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"Url\" TEXT NULL,\n \"Logo\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"EncryptionKeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\nCREATE TABLE \"Settings\" (\n \"Key\" TEXT NOT NULL CONSTRAINT \"PK_Settings\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0\n);\n\n-- Tables with foreign keys\nCREATE TABLE \"Credentials\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Credentials\" PRIMARY KEY,\n \"AliasId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Notes\" TEXT NULL,\n \"ServiceId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Username\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_Credentials_Aliases_AliasId\" FOREIGN KEY (\"AliasId\") REFERENCES \"Aliases\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_Credentials_Services_ServiceId\" FOREIGN KEY (\"ServiceId\") REFERENCES \"Services\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Passwords\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passwords\" PRIMARY KEY,\n \"Value\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_Passwords_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL DEFAULT 0,\n CONSTRAINT \"FK_TotpCodes_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\n\n-- Restore data from temp tables\nINSERT INTO \"__EFMigrationsHistory\" SELECT * FROM \"__EFMigrationsHistory_temp\";\nINSERT INTO \"Aliases\" SELECT * FROM \"Aliases_temp\";\nINSERT INTO \"Services\" SELECT * FROM \"Services_temp\";\nINSERT INTO \"EncryptionKeys\" SELECT * FROM \"EncryptionKeys_temp\";\nINSERT INTO \"Settings\" SELECT * FROM \"Settings_temp\";\nINSERT INTO \"Credentials\" SELECT * FROM \"Credentials_temp\";\nINSERT INTO \"Attachments\" SELECT * FROM \"Attachments_temp\";\nINSERT INTO \"Passwords\" SELECT * FROM \"Passwords_temp\";\nINSERT INTO \"TotpCodes\" SELECT * FROM \"TotpCodes_temp\";\n\n-- =====================================================================================\n-- Date Format Normalization Migration\n-- =====================================================================================\n-- This migration normalizes ALL date fields to the standard format: 'yyyy-MM-dd HH:mm:ss.fff'\n-- Previously the different clients used different date formats which complicate date parsing.\n-- From version 0.24.0 onwards, all new dates are stored in this standard format.\n\n-- Update Aliases table (CreatedAt, UpdatedAt, BirthDate)\nUPDATE \"Aliases\" SET \"CreatedAt\" =\n CASE\n -- Already in correct format (yyyy-MM-dd HH:mm:ss.fff) - no change\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n\n -- ISO 8601 with milliseconds (yyyy-MM-ddTHH:mm:ss.fffZ) -> Replace T with space, remove Z and everything after .fff\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n\n -- Without milliseconds (yyyy-MM-dd HH:mm:ss or yyyy-MM-ddTHH:mm:ssZ) -> Add .000\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n\n -- Fallback: if none match, keep as-is (edge case)\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Aliases\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- BirthDate: Always set time to 00:00:00 (no milliseconds for birth dates)\nUPDATE \"Aliases\" SET \"BirthDate\" =\n CASE\n -- If empty or already '0001-01-01 00:00:00', keep as-is\n WHEN \"BirthDate\" = '' OR \"BirthDate\" = '0001-01-01 00:00:00'\n THEN \"BirthDate\"\n\n -- If already in correct format (yyyy-MM-dd 00:00:00), keep as-is\n WHEN \"BirthDate\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] 00:00:00'\n THEN \"BirthDate\"\n\n -- Extract date part and set time to 00:00:00\n WHEN \"BirthDate\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*'\n THEN substr(\"BirthDate\", 1, 10) || ' 00:00:00'\n\n -- Fallback\n ELSE \"BirthDate\"\n END;\n\n-- Update Services table (CreatedAt, UpdatedAt)\nUPDATE \"Services\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Services\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update EncryptionKeys table (CreatedAt, UpdatedAt)\nUPDATE \"EncryptionKeys\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"EncryptionKeys\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Settings table (CreatedAt, UpdatedAt)\nUPDATE \"Settings\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Settings\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Credentials table (CreatedAt, UpdatedAt)\nUPDATE \"Credentials\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Credentials\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Attachments table (CreatedAt, UpdatedAt)\nUPDATE \"Attachments\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Attachments\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update Passwords table (CreatedAt, UpdatedAt)\nUPDATE \"Passwords\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"Passwords\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- Update TotpCodes table (CreatedAt, UpdatedAt)\nUPDATE \"TotpCodes\" SET \"CreatedAt\" =\n CASE\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"CreatedAt\"\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(\"CreatedAt\", 12, 12)\n WHEN \"CreatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"CreatedAt\", 1, 10) || ' ' || substr(replace(\"CreatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"CreatedAt\"\n END;\n\nUPDATE \"TotpCodes\" SET \"UpdatedAt\" =\n CASE\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]'\n THEN \"UpdatedAt\"\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(\"UpdatedAt\", 12, 12)\n WHEN \"UpdatedAt\" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][T ][0-9][0-9]:[0-9][0-9]:[0-9][0-9]*'\n THEN substr(\"UpdatedAt\", 1, 10) || ' ' || substr(replace(\"UpdatedAt\", 'T', ' '), 12, 8) || '.000'\n ELSE \"UpdatedAt\"\n END;\n\n-- =====================================================================================\n-- End of Date Format Normalization Migration\n-- =====================================================================================\n\n-- Recreate indexes\nCREATE INDEX \"IX_Credentials_AliasId\" ON \"Credentials\" (\"AliasId\");\nCREATE INDEX \"IX_Credentials_ServiceId\" ON \"Credentials\" (\"ServiceId\");\nCREATE INDEX \"IX_Attachments_CredentialId\" ON \"Attachments\" (\"CredentialId\");\nCREATE INDEX \"IX_Passwords_CredentialId\" ON \"Passwords\" (\"CredentialId\");\nCREATE INDEX \"IX_TotpCodes_CredentialId\" ON \"TotpCodes\" (\"CredentialId\");\n\n-- Clean up temp tables\nDROP TABLE \"__EFMigrationsHistory_temp\";\nDROP TABLE \"Aliases_temp\";\nDROP TABLE \"Services_temp\";\nDROP TABLE \"EncryptionKeys_temp\";\nDROP TABLE \"Settings_temp\";\nDROP TABLE \"Credentials_temp\";\nDROP TABLE \"Attachments_temp\";\nDROP TABLE \"Passwords_temp\";\nDROP TABLE \"TotpCodes_temp\";\n\nPRAGMA foreign_keys = ON;\n\n\nCREATE TABLE \"Passkeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passkeys\" PRIMARY KEY,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"AdditionalData\" BLOB NULL,\n \"CredentialId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Passkeys_Credentials_CredentialId\" FOREIGN KEY (\"CredentialId\") REFERENCES \"Credentials\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_Passkeys_CredentialId\" ON \"Passkeys\" (\"CredentialId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20251014122838_1.6.0-AddPasskeys', '10.0.10');\n\nCOMMIT;\n\nPRAGMA foreign_keys = OFF;\n\nBEGIN TRANSACTION;\nALTER TABLE \"TotpCodes\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_TotpCodes_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_TotpCodes_ItemId\" ON \"TotpCodes\" (\"ItemId\");\n\nALTER TABLE \"Passkeys\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_Passkeys_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_Passkeys_ItemId\" ON \"Passkeys\" (\"ItemId\");\n\nALTER TABLE \"Attachments\" RENAME COLUMN \"CredentialId\" TO \"ItemId\";\n\nDROP INDEX IF EXISTS \"IX_Attachments_CredentialId\";\n\nCREATE INDEX IF NOT EXISTS \"IX_Attachments_ItemId\" ON \"Attachments\" (\"ItemId\");\n\nCREATE TABLE \"FieldDefinitions\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldDefinitions\" PRIMARY KEY,\n \"FieldType\" TEXT NOT NULL,\n \"Label\" TEXT NOT NULL,\n \"IsMultiValue\" INTEGER NOT NULL,\n \"IsHidden\" INTEGER NOT NULL,\n \"EnableHistory\" INTEGER NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"ApplicableToTypes\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Folders\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Folders\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"ParentFolderId\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Folders_Folders_ParentFolderId\" FOREIGN KEY (\"ParentFolderId\") REFERENCES \"Folders\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"Logos\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Logos\" PRIMARY KEY,\n \"Source\" TEXT NOT NULL,\n \"FileData\" BLOB NULL,\n \"MimeType\" TEXT NULL,\n \"FetchedAt\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Tags\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Tags\" PRIMARY KEY,\n \"Name\" TEXT NOT NULL,\n \"Color\" TEXT NULL,\n \"DisplayOrder\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL\n);\n\nCREATE TABLE \"Items\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Items\" PRIMARY KEY,\n \"Name\" TEXT NULL,\n \"ItemType\" TEXT NOT NULL,\n \"LogoId\" TEXT NULL,\n \"DeletedAt\" TEXT NULL,\n \"FolderId\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_Items_Folders_FolderId\" FOREIGN KEY (\"FolderId\") REFERENCES \"Folders\" (\"Id\") ON DELETE SET NULL,\n CONSTRAINT \"FK_Items_Logos_LogoId\" FOREIGN KEY (\"LogoId\") REFERENCES \"Logos\" (\"Id\") ON DELETE SET NULL\n);\n\nCREATE TABLE \"FieldHistories\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldHistories\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"ValueSnapshot\" TEXT NOT NULL,\n \"ChangedAt\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_FieldHistories_FieldDefinitions_FieldDefinitionId\" FOREIGN KEY (\"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldHistories_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"FieldValues\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_FieldValues\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"Value\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_FieldValues_FieldDefinitions_FieldDefinitionId\" FOREIGN KEY (\"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldValues_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE TABLE \"ItemTags\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_ItemTags\" PRIMARY KEY,\n \"ItemId\" TEXT NOT NULL,\n \"TagId\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"FK_ItemTags_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_ItemTags_Tags_TagId\" FOREIGN KEY (\"TagId\") REFERENCES \"Tags\" (\"Id\") ON DELETE CASCADE\n);\n\nCREATE INDEX \"IX_FieldHistories_FieldDefinitionId\" ON \"FieldHistories\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ItemId\" ON \"FieldHistories\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_FieldDefinitionId\" ON \"FieldValues\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_FieldKey\" ON \"FieldValues\" (\"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ItemId\" ON \"FieldValues\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldDefinitionId_Weight\" ON \"FieldValues\" (\"ItemId\", \"FieldDefinitionId\", \"Weight\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldKey\" ON \"FieldValues\" (\"ItemId\", \"FieldKey\");\n\nCREATE INDEX \"IX_Folders_ParentFolderId\" ON \"Folders\" (\"ParentFolderId\");\n\nCREATE INDEX \"IX_Items_FolderId\" ON \"Items\" (\"FolderId\");\n\nCREATE INDEX \"IX_Items_LogoId\" ON \"Items\" (\"LogoId\");\n\nCREATE INDEX \"IX_ItemTags_ItemId\" ON \"ItemTags\" (\"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ItemId_TagId\" ON \"ItemTags\" (\"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_TagId\" ON \"ItemTags\" (\"TagId\");\n\nCREATE UNIQUE INDEX \"IX_Logos_Source\" ON \"Logos\" (\"Source\");\n\nCREATE INDEX \"IX_Tags_Name\" ON \"Tags\" (\"Name\");\n\n\n INSERT INTO Items (Id, Name, ItemType, LogoId, FolderId, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n c.Id,\n s.Name AS Name,\n CASE\n WHEN a.Id IS NOT NULL AND (\n (a.FirstName IS NOT NULL AND a.FirstName != '') OR\n (a.LastName IS NOT NULL AND a.LastName != '') OR\n (a.Gender IS NOT NULL AND a.Gender != '') OR\n (a.BirthDate IS NOT NULL AND a.BirthDate != '' AND a.BirthDate NOT LIKE '0001-%')\n ) THEN 'Alias'\n ELSE 'Login'\n END AS ItemType,\n NULL AS LogoId,\n NULL AS FolderId,\n c.CreatedAt,\n c.UpdatedAt,\n c.IsDeleted\n FROM Credentials c\n LEFT JOIN Services s ON s.Id = c.ServiceId\n LEFT JOIN Aliases a ON a.Id = c.AliasId;\n \n\n\n INSERT INTO Logos (Id, Source, FileData, MimeType, FetchedAt, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n -- Extract and normalize hostname: remove protocol, path, lowercase, and www. prefix\n REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n ) AS Source,\n s.Logo AS FileData,\n 'image/png' AS MimeType,\n NULL AS FetchedAt,\n MIN(s.CreatedAt) AS CreatedAt,\n MAX(s.UpdatedAt) AS UpdatedAt,\n 0 AS IsDeleted\n FROM Services s\n WHERE s.Logo IS NOT NULL AND s.Url IS NOT NULL AND s.Url != ''\n GROUP BY REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n );\n \n\n\n UPDATE Items\n SET LogoId = (\n SELECT l.Id FROM Logos l\n INNER JOIN Services s ON REPLACE(\n LOWER(\n SUBSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END,\n 1,\n CASE\n WHEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') > 0\n THEN INSTR(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END, '/') - 1\n ELSE LENGTH(\n CASE\n WHEN s.Url LIKE 'https://%' THEN SUBSTR(s.Url, 9)\n WHEN s.Url LIKE 'http://%' THEN SUBSTR(s.Url, 8)\n ELSE s.Url\n END)\n END\n )\n ),\n 'www.', ''\n ) = l.Source\n INNER JOIN Credentials c ON c.ServiceId = s.Id\n WHERE c.Id = Items.Id\n LIMIT 1\n )\n WHERE EXISTS (\n SELECT 1 FROM Credentials c\n INNER JOIN Services s ON s.Id = c.ServiceId\n WHERE c.Id = Items.Id AND s.Logo IS NOT NULL\n );\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.url' AS FieldKey,\n s.Url AS Value,\n 0 AS Weight,\n s.UpdatedAt AS CreatedAt,\n s.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Services s ON s.Id = c.ServiceId\n WHERE s.Url IS NOT NULL AND s.Url != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.username' AS FieldKey,\n c.Username AS Value,\n 0 AS Weight,\n c.UpdatedAt AS CreatedAt,\n c.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n WHERE c.Username IS NOT NULL AND c.Username != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'notes.content' AS FieldKey,\n c.Notes AS Value,\n 0 AS Weight,\n c.UpdatedAt AS CreatedAt,\n c.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n WHERE c.Notes IS NOT NULL AND c.Notes != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n p.CredentialId AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.password' AS FieldKey,\n p.Value AS Value,\n 0 AS Weight,\n p.UpdatedAt AS CreatedAt,\n p.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Passwords p\n INNER JOIN (\n SELECT CredentialId, MAX(UpdatedAt) AS MaxUpdated, MAX(Id) AS MaxId\n FROM Passwords\n WHERE IsDeleted = 0\n GROUP BY CredentialId\n ) pm ON p.CredentialId = pm.CredentialId AND p.UpdatedAt = pm.MaxUpdated AND p.Id = pm.MaxId\n WHERE p.IsDeleted = 0;\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'login.email' AS FieldKey,\n a.Email AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.Email IS NOT NULL AND a.Email != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.first_name' AS FieldKey,\n a.FirstName AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.FirstName IS NOT NULL AND a.FirstName != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.last_name' AS FieldKey,\n a.LastName AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.LastName IS NOT NULL AND a.LastName != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.gender' AS FieldKey,\n a.Gender AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.Gender IS NOT NULL AND a.Gender != '';\n \n\n\n INSERT INTO FieldValues (Id, ItemId, FieldDefinitionId, FieldKey, Value, Weight, CreatedAt, UpdatedAt, IsDeleted)\n SELECT\n UPPER(SUBSTR(hex(randomblob(4)), 1, 8) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(2)), 1, 4) || '-' ||\n SUBSTR(hex(randomblob(6)), 1, 12)) AS Id,\n c.Id AS ItemId,\n NULL AS FieldDefinitionId,\n 'alias.birthdate' AS FieldKey,\n SUBSTR(a.BirthDate, 1, 10) AS Value,\n 0 AS Weight,\n a.UpdatedAt AS CreatedAt,\n a.UpdatedAt AS UpdatedAt,\n 0 AS IsDeleted\n FROM Credentials c\n INNER JOIN Aliases a ON a.Id = c.AliasId\n WHERE a.BirthDate IS NOT NULL AND a.BirthDate != '' AND a.BirthDate NOT LIKE '0001-%';\n \n\nDROP TABLE \"Passwords\";\n\nDROP TABLE \"Credentials\";\n\nDROP TABLE \"Aliases\";\n\nDROP TABLE \"Services\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = ON;\n\nBEGIN TRANSACTION;\nCREATE TABLE \"ef_temp_Attachments\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Attachments\" PRIMARY KEY,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_Attachments_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\")\nSELECT \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCREATE TABLE \"ef_temp_Passkeys\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Passkeys\" PRIMARY KEY,\n \"AdditionalData\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n CONSTRAINT \"FK_Passkeys_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Passkeys\" (\"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\")\nSELECT \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\"\nFROM \"Passkeys\";\n\nCREATE TABLE \"ef_temp_TotpCodes\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"FK_TotpCodes_Items_ItemId\" FOREIGN KEY (\"ItemId\") REFERENCES \"Items\" (\"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_TotpCodes\" (\"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\")\nSELECT \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\"\nFROM \"TotpCodes\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nDROP TABLE \"Passkeys\";\n\nALTER TABLE \"ef_temp_Passkeys\" RENAME TO \"Passkeys\";\n\nDROP TABLE \"TotpCodes\";\n\nALTER TABLE \"ef_temp_TotpCodes\" RENAME TO \"TotpCodes\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_ItemId\" ON \"Attachments\" (\"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_ItemId\" ON \"Passkeys\" (\"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nCREATE INDEX \"IX_TotpCodes_ItemId\" ON \"TotpCodes\" (\"ItemId\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20251213111207_1.7.0-FieldBasedDataModelUpdate', '10.0.10');\n\nBEGIN TRANSACTION;\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260130221620_2.0.0-MajorVersionBump', '10.0.10');\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP INDEX \"IX_TotpCodes_ItemId\";\n\nDROP INDEX \"IX_Tags_Name\";\n\nDROP INDEX \"IX_Passkeys_ItemId\";\n\nDROP INDEX \"IX_Logos_Source\";\n\nDROP INDEX \"IX_ItemTags_ItemId_TagId\";\n\nDROP INDEX \"IX_Items_FolderId\";\n\nDROP INDEX \"IX_Items_LogoId\";\n\nDROP INDEX \"IX_Attachments_ItemId\";\n\nALTER TABLE \"TotpCodes\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Tags\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Settings\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Passkeys\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Logos\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Logos\" ADD \"Kind\" TEXT NOT NULL DEFAULT 'favicon';\n\nALTER TABLE \"Logos\" ADD \"Name\" TEXT NULL;\n\nALTER TABLE \"ItemTags\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Items\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Folders\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldValues\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldHistories\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"FieldDefinitions\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"EncryptionKeys\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nALTER TABLE \"Attachments\" ADD \"ManifestId\" TEXT NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';\n\nCREATE TABLE \"CodecOverflows\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_CodecOverflows\" PRIMARY KEY,\n \"Data\" TEXT NOT NULL\n);\n\nCREATE TABLE \"ItemStats\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"LastUsedAt\" TEXT NULL,\n \"UseCount\" INTEGER NOT NULL,\n \"LastAutofilledAt\" TEXT NULL,\n \"AutofillCount\" INTEGER NOT NULL,\n \"LastCopiedAt\" TEXT NULL,\n \"CopyCount\" INTEGER NOT NULL,\n \"LastPasskeyAuthAt\" TEXT NULL,\n \"PasskeyAuthCount\" INTEGER NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n CONSTRAINT \"PK_ItemStats\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nCREATE TABLE \"Manifests\" (\n \"Id\" TEXT NOT NULL CONSTRAINT \"PK_Manifests\" PRIMARY KEY,\n \"Name\" TEXT NULL\n);\n\nCREATE INDEX \"IX_TotpCodes_ManifestId_ItemId\" ON \"TotpCodes\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Tags_ManifestId_Name\" ON \"Tags\" (\"ManifestId\", \"Name\");\n\nCREATE INDEX \"IX_Passkeys_ManifestId_ItemId\" ON \"Passkeys\" (\"ManifestId\", \"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_Logos_ManifestId_Kind_Source\" ON \"Logos\" (\"ManifestId\", \"Kind\", \"Source\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ManifestId_ItemId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_ManifestId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"TagId\");\n\nCREATE INDEX \"IX_Items_ManifestId_FolderId\" ON \"Items\" (\"ManifestId\", \"FolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_LogoId\" ON \"Items\" (\"ManifestId\", \"LogoId\");\n\nCREATE INDEX \"IX_Folders_ManifestId_ParentFolderId\" ON \"Folders\" (\"ManifestId\", \"ParentFolderId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_FieldDefinitionId\" ON \"FieldValues\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_ItemId\" ON \"FieldValues\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_FieldDefinitionId\" ON \"FieldHistories\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_ItemId\" ON \"FieldHistories\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_EncryptionKeys_ManifestId_IsPrimary\" ON \"EncryptionKeys\" (\"ManifestId\", \"IsPrimary\");\n\nCREATE INDEX \"IX_Attachments_ManifestId_ItemId\" ON \"Attachments\" (\"ManifestId\", \"ItemId\");\n\nCREATE TABLE \"ef_temp_Attachments\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"Blob\" BLOB NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"Filename\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Attachments\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Attachments_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Attachments\" (\"ManifestId\", \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"Blob\", \"CreatedAt\", \"Filename\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\"\nFROM \"Attachments\";\n\nCREATE TABLE \"ef_temp_FieldHistories\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"ChangedAt\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"ValueSnapshot\" TEXT NOT NULL,\n CONSTRAINT \"PK_FieldHistories\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_FieldHistories_FieldDefinitions_ManifestId_FieldDefinitionId\" FOREIGN KEY (\"ManifestId\", \"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldHistories_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_FieldHistories\" (\"ManifestId\", \"Id\", \"ChangedAt\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"ValueSnapshot\")\nSELECT \"ManifestId\", \"Id\", \"ChangedAt\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"ValueSnapshot\"\nFROM \"FieldHistories\";\n\nCREATE TABLE \"ef_temp_FieldValues\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FieldDefinitionId\" TEXT NULL,\n \"FieldKey\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Value\" TEXT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_FieldValues\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_FieldValues_FieldDefinitions_ManifestId_FieldDefinitionId\" FOREIGN KEY (\"ManifestId\", \"FieldDefinitionId\") REFERENCES \"FieldDefinitions\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_FieldValues_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_FieldValues\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"Value\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"FieldDefinitionId\", \"FieldKey\", \"IsDeleted\", \"ItemId\", \"UpdatedAt\", \"Value\", \"Weight\"\nFROM \"FieldValues\";\n\nCREATE TABLE \"ef_temp_Folders\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"ParentFolderId\" TEXT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_Folders\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Folders_Folders_ManifestId_ParentFolderId\" FOREIGN KEY (\"ManifestId\", \"ParentFolderId\") REFERENCES \"Folders\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Folders\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"Name\", \"ParentFolderId\", \"UpdatedAt\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"Name\", \"ParentFolderId\", \"UpdatedAt\", \"Weight\"\nFROM \"Folders\";\n\nCREATE TABLE \"ef_temp_Items\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DeletedAt\" TEXT NULL,\n \"FolderId\" TEXT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemType\" TEXT NOT NULL,\n \"LogoId\" TEXT NULL,\n \"Name\" TEXT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Items\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Items_Folders_ManifestId_FolderId\" FOREIGN KEY (\"ManifestId\", \"FolderId\") REFERENCES \"Folders\" (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Items_Logos_ManifestId_LogoId\" FOREIGN KEY (\"ManifestId\", \"LogoId\") REFERENCES \"Logos\" (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Items\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"DeletedAt\", \"FolderId\", \"IsDeleted\", \"ItemType\", \"LogoId\", \"Name\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"DeletedAt\", \"FolderId\", \"IsDeleted\", \"ItemType\", \"LogoId\", \"Name\", \"UpdatedAt\"\nFROM \"Items\";\n\nCREATE TABLE \"ef_temp_ItemTags\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"TagId\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_ItemTags\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_ItemTags_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE,\n CONSTRAINT \"FK_ItemTags_Tags_ManifestId_TagId\" FOREIGN KEY (\"ManifestId\", \"TagId\") REFERENCES \"Tags\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_ItemTags\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"TagId\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"TagId\", \"UpdatedAt\"\nFROM \"ItemTags\";\n\nCREATE TABLE \"ef_temp_Passkeys\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"AdditionalData\" BLOB NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayName\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"PrfKey\" BLOB NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"RpId\" TEXT COLLATE NOCASE NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"UserHandle\" BLOB NOT NULL,\n CONSTRAINT \"PK_Passkeys\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_Passkeys_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_Passkeys\" (\"ManifestId\", \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\")\nSELECT \"ManifestId\", \"Id\", \"AdditionalData\", \"CreatedAt\", \"DisplayName\", \"IsDeleted\", \"ItemId\", \"PrfKey\", \"PrivateKey\", \"PublicKey\", \"RpId\", \"UpdatedAt\", \"UserHandle\"\nFROM \"Passkeys\";\n\nCREATE TABLE \"ef_temp_TotpCodes\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"ItemId\" TEXT NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"SecretKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_TotpCodes\" PRIMARY KEY (\"ManifestId\", \"Id\"),\n CONSTRAINT \"FK_TotpCodes_Items_ManifestId_ItemId\" FOREIGN KEY (\"ManifestId\", \"ItemId\") REFERENCES \"Items\" (\"ManifestId\", \"Id\") ON DELETE CASCADE\n);\n\nINSERT INTO \"ef_temp_TotpCodes\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"ItemId\", \"Name\", \"SecretKey\", \"UpdatedAt\"\nFROM \"TotpCodes\";\n\nCREATE TABLE \"ef_temp_Tags\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"Color\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"DisplayOrder\" INTEGER NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Name\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Tags\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Tags\" (\"ManifestId\", \"Id\", \"Color\", \"CreatedAt\", \"DisplayOrder\", \"IsDeleted\", \"Name\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"Color\", \"CreatedAt\", \"DisplayOrder\", \"IsDeleted\", \"Name\", \"UpdatedAt\"\nFROM \"Tags\";\n\nCREATE TABLE \"ef_temp_Settings\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Key\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Value\" TEXT NULL,\n CONSTRAINT \"PK_Settings\" PRIMARY KEY (\"ManifestId\", \"Key\")\n);\n\nINSERT INTO \"ef_temp_Settings\" (\"ManifestId\", \"Key\", \"CreatedAt\", \"IsDeleted\", \"UpdatedAt\", \"Value\")\nSELECT \"ManifestId\", \"Key\", \"CreatedAt\", \"IsDeleted\", \"UpdatedAt\", \"Value\"\nFROM \"Settings\";\n\nCREATE TABLE \"ef_temp_Logos\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"FetchedAt\" TEXT NULL,\n \"FileData\" BLOB NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"Kind\" TEXT NOT NULL DEFAULT 'favicon',\n \"MimeType\" TEXT NULL,\n \"Name\" TEXT NULL,\n \"Source\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_Logos\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_Logos\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"FetchedAt\", \"FileData\", \"IsDeleted\", \"Kind\", \"MimeType\", \"Name\", \"Source\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"FetchedAt\", \"FileData\", \"IsDeleted\", \"Kind\", \"MimeType\", \"Name\", \"Source\", \"UpdatedAt\"\nFROM \"Logos\";\n\nCREATE TABLE \"ef_temp_FieldDefinitions\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"ApplicableToTypes\" TEXT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"EnableHistory\" INTEGER NOT NULL,\n \"FieldType\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"IsHidden\" INTEGER NOT NULL,\n \"IsMultiValue\" INTEGER NOT NULL,\n \"Label\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n \"Weight\" INTEGER NOT NULL,\n CONSTRAINT \"PK_FieldDefinitions\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_FieldDefinitions\" (\"ManifestId\", \"Id\", \"ApplicableToTypes\", \"CreatedAt\", \"EnableHistory\", \"FieldType\", \"IsDeleted\", \"IsHidden\", \"IsMultiValue\", \"Label\", \"UpdatedAt\", \"Weight\")\nSELECT \"ManifestId\", \"Id\", \"ApplicableToTypes\", \"CreatedAt\", \"EnableHistory\", \"FieldType\", \"IsDeleted\", \"IsHidden\", \"IsMultiValue\", \"Label\", \"UpdatedAt\", \"Weight\"\nFROM \"FieldDefinitions\";\n\nCREATE TABLE \"ef_temp_EncryptionKeys\" (\n \"ManifestId\" TEXT NOT NULL,\n \"Id\" TEXT NOT NULL,\n \"CreatedAt\" TEXT NOT NULL,\n \"IsDeleted\" INTEGER NOT NULL,\n \"IsPrimary\" INTEGER NOT NULL,\n \"PrivateKey\" TEXT NOT NULL,\n \"PublicKey\" TEXT NOT NULL,\n \"UpdatedAt\" TEXT NOT NULL,\n CONSTRAINT \"PK_EncryptionKeys\" PRIMARY KEY (\"ManifestId\", \"Id\")\n);\n\nINSERT INTO \"ef_temp_EncryptionKeys\" (\"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"IsPrimary\", \"PrivateKey\", \"PublicKey\", \"UpdatedAt\")\nSELECT \"ManifestId\", \"Id\", \"CreatedAt\", \"IsDeleted\", \"IsPrimary\", \"PrivateKey\", \"PublicKey\", \"UpdatedAt\"\nFROM \"EncryptionKeys\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 0;\n\nBEGIN TRANSACTION;\nDROP TABLE \"Attachments\";\n\nALTER TABLE \"ef_temp_Attachments\" RENAME TO \"Attachments\";\n\nDROP TABLE \"FieldHistories\";\n\nALTER TABLE \"ef_temp_FieldHistories\" RENAME TO \"FieldHistories\";\n\nDROP TABLE \"FieldValues\";\n\nALTER TABLE \"ef_temp_FieldValues\" RENAME TO \"FieldValues\";\n\nDROP TABLE \"Folders\";\n\nALTER TABLE \"ef_temp_Folders\" RENAME TO \"Folders\";\n\nDROP TABLE \"Items\";\n\nALTER TABLE \"ef_temp_Items\" RENAME TO \"Items\";\n\nDROP TABLE \"ItemTags\";\n\nALTER TABLE \"ef_temp_ItemTags\" RENAME TO \"ItemTags\";\n\nDROP TABLE \"Passkeys\";\n\nALTER TABLE \"ef_temp_Passkeys\" RENAME TO \"Passkeys\";\n\nDROP TABLE \"TotpCodes\";\n\nALTER TABLE \"ef_temp_TotpCodes\" RENAME TO \"TotpCodes\";\n\nDROP TABLE \"Tags\";\n\nALTER TABLE \"ef_temp_Tags\" RENAME TO \"Tags\";\n\nDROP TABLE \"Settings\";\n\nALTER TABLE \"ef_temp_Settings\" RENAME TO \"Settings\";\n\nDROP TABLE \"Logos\";\n\nALTER TABLE \"ef_temp_Logos\" RENAME TO \"Logos\";\n\nDROP TABLE \"FieldDefinitions\";\n\nALTER TABLE \"ef_temp_FieldDefinitions\" RENAME TO \"FieldDefinitions\";\n\nDROP TABLE \"EncryptionKeys\";\n\nALTER TABLE \"ef_temp_EncryptionKeys\" RENAME TO \"EncryptionKeys\";\n\nCOMMIT;\n\nPRAGMA foreign_keys = 1;\n\nBEGIN TRANSACTION;\nCREATE INDEX \"IX_Attachments_ManifestId_ItemId\" ON \"Attachments\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_FieldDefinitionId\" ON \"FieldHistories\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ItemId\" ON \"FieldHistories\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_FieldDefinitionId\" ON \"FieldHistories\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldHistories_ManifestId_ItemId\" ON \"FieldHistories\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_FieldDefinitionId\" ON \"FieldValues\" (\"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_FieldKey\" ON \"FieldValues\" (\"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ItemId\" ON \"FieldValues\" (\"ItemId\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldDefinitionId_Weight\" ON \"FieldValues\" (\"ItemId\", \"FieldDefinitionId\", \"Weight\");\n\nCREATE INDEX \"IX_FieldValues_ItemId_FieldKey\" ON \"FieldValues\" (\"ItemId\", \"FieldKey\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_FieldDefinitionId\" ON \"FieldValues\" (\"ManifestId\", \"FieldDefinitionId\");\n\nCREATE INDEX \"IX_FieldValues_ManifestId_ItemId\" ON \"FieldValues\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Folders_ManifestId_ParentFolderId\" ON \"Folders\" (\"ManifestId\", \"ParentFolderId\");\n\nCREATE INDEX \"IX_Folders_ParentFolderId\" ON \"Folders\" (\"ParentFolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_FolderId\" ON \"Items\" (\"ManifestId\", \"FolderId\");\n\nCREATE INDEX \"IX_Items_ManifestId_LogoId\" ON \"Items\" (\"ManifestId\", \"LogoId\");\n\nCREATE INDEX \"IX_ItemTags_ItemId\" ON \"ItemTags\" (\"ItemId\");\n\nCREATE UNIQUE INDEX \"IX_ItemTags_ManifestId_ItemId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"ItemId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_ManifestId_TagId\" ON \"ItemTags\" (\"ManifestId\", \"TagId\");\n\nCREATE INDEX \"IX_ItemTags_TagId\" ON \"ItemTags\" (\"TagId\");\n\nCREATE INDEX \"IX_Passkeys_ManifestId_ItemId\" ON \"Passkeys\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Passkeys_RpId\" ON \"Passkeys\" (\"RpId\");\n\nCREATE INDEX \"IX_TotpCodes_ManifestId_ItemId\" ON \"TotpCodes\" (\"ManifestId\", \"ItemId\");\n\nCREATE INDEX \"IX_Tags_ManifestId_Name\" ON \"Tags\" (\"ManifestId\", \"Name\");\n\nCREATE UNIQUE INDEX \"IX_Logos_ManifestId_Kind_Source\" ON \"Logos\" (\"ManifestId\", \"Kind\", \"Source\");\n\nCREATE INDEX \"IX_EncryptionKeys_ManifestId_IsPrimary\" ON \"EncryptionKeys\" (\"ManifestId\", \"IsPrimary\");\n\nCOMMIT;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260809201530_2.1.0-ManifestScopedStorage', '10.0.10');\n\nBEGIN TRANSACTION;\nCREATE TRIGGER IF NOT EXISTS \"TR_Items_ResyncChildManifestIds\"\nAFTER UPDATE OF \"ManifestId\" ON \"Items\"\nFOR EACH ROW WHEN OLD.\"ManifestId\" <> NEW.\"ManifestId\"\nBEGIN\n UPDATE \"FieldValues\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"FieldHistories\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"ItemTags\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"Attachments\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"Passkeys\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"TotpCodes\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"ItemId\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\n UPDATE \"ItemStats\" SET \"ManifestId\" = NEW.\"ManifestId\" WHERE \"Id\" = NEW.\"Id\" AND \"ManifestId\" = OLD.\"ManifestId\";\nEND;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260809201914_2.1.1-ItemChildManifestTrigger', '10.0.10');\n\nCOMMIT;\n\nBEGIN TRANSACTION;\nALTER TABLE \"TotpCodes\" ADD \"Algorithm\" TEXT NOT NULL DEFAULT 'SHA1';\n\nALTER TABLE \"TotpCodes\" ADD \"Digits\" INTEGER NOT NULL DEFAULT 6;\n\nALTER TABLE \"TotpCodes\" ADD \"Period\" INTEGER NOT NULL DEFAULT 30;\n\nINSERT INTO \"__EFMigrationsHistory\" (\"MigrationId\", \"ProductVersion\")\nVALUES ('20260810093834_2.1.2-AddTotpParameters', '10.0.10');\n\nCOMMIT;\n";
/**
* Individual migration SQL scripts
* Auto-generated from EF Core migrations
diff --git a/apps/browser-extension/src/utils/dist/core/vault/index.js b/apps/browser-extension/src/utils/dist/core/vault/index.js
index 5ee3df34c..c01bb0c25 100644
--- a/apps/browser-extension/src/utils/dist/core/vault/index.js
+++ b/apps/browser-extension/src/utils/dist/core/vault/index.js
@@ -1811,6 +1811,18 @@ END;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20260809201914_2.1.1-ItemChildManifestTrigger', '10.0.10');
+COMMIT;
+
+BEGIN TRANSACTION;
+ALTER TABLE "TotpCodes" ADD "Algorithm" TEXT NOT NULL DEFAULT 'SHA1';
+
+ALTER TABLE "TotpCodes" ADD "Digits" INTEGER NOT NULL DEFAULT 6;
+
+ALTER TABLE "TotpCodes" ADD "Period" INTEGER NOT NULL DEFAULT 30;
+
+INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
+VALUES ('20260810093834_2.1.2-AddTotpParameters', '10.0.10');
+
COMMIT;
`;
var MIGRATION_SCRIPTS = {
diff --git a/apps/browser-extension/src/utils/dist/core/vault/index.mjs b/apps/browser-extension/src/utils/dist/core/vault/index.mjs
index c757f2700..2622ec4c4 100644
--- a/apps/browser-extension/src/utils/dist/core/vault/index.mjs
+++ b/apps/browser-extension/src/utils/dist/core/vault/index.mjs
@@ -1779,6 +1779,18 @@ END;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20260809201914_2.1.1-ItemChildManifestTrigger', '10.0.10');
+COMMIT;
+
+BEGIN TRANSACTION;
+ALTER TABLE "TotpCodes" ADD "Algorithm" TEXT NOT NULL DEFAULT 'SHA1';
+
+ALTER TABLE "TotpCodes" ADD "Digits" INTEGER NOT NULL DEFAULT 6;
+
+ALTER TABLE "TotpCodes" ADD "Period" INTEGER NOT NULL DEFAULT 30;
+
+INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
+VALUES ('20260810093834_2.1.2-AddTotpParameters', '10.0.10');
+
COMMIT;
`;
var MIGRATION_SCRIPTS = {
diff --git a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
index a352314e7..7b6d81a2e 100644
--- a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
+++ b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
@@ -6,6 +6,17 @@
import { defineExtensionMessaging } from '@webext-core/messaging';
+/**
+ * An item's TOTP secret plus the RFC 6238 parameters its codes must be generated with. The content
+ * script renders codes itself, so the parameters have to cross the boundary alongside the secret.
+ */
+export type TotpSecret = {
+ SecretKey: string;
+ Algorithm: string;
+ Digits: number;
+ Period: number;
+};
+
import type { TwoFactorState } from '@/entrypoints/background/TwoFactorStateHandler';
import type { FullVaultSyncResult, VaultManifestMigrationResult, VaultSyncPhase } from '@/entrypoints/background/VaultMessageHandler';
@@ -72,7 +83,7 @@ export interface IExtensionMessageProtocol {
GET_SAVE_PROMPT_STATE(): { success: boolean; state: SavePromptPersistedState | null };
GET_SEARCH_ITEMS(data: { searchTerm: string }): ItemsResponse;
GET_SYNC_STATE(): { isDirty: boolean; mutationSequence: number; isSyncInProgress: boolean };
- GET_TOTP_SECRETS(data: { itemIds: string[] }): { success: boolean; secrets?: Record<string, string>; error?: string };
+ GET_TOTP_SECRETS(data: { itemIds: string[] }): { success: boolean; secrets?: Record<string, TotpSecret>; error?: string };
GET_TWO_FACTOR_STATE(): TwoFactorState | null;
GET_VAULT(): VaultResponse;
GET_WEBAUTHN_SETTINGS(data: any): WebAuthnSettingsResponse;