@ -36,15 +36,11 @@ const MIGRATIONS = [
{
{
name : "001_initial" ,
name : "001_initial" ,
sql : `
sql : `
-- Enable foreign key constraints for data integrity
PRAGMA foreign_keys = ON ;
-- Create accounts table with UNIQUE constraint on did
CREATE TABLE IF NOT EXISTS accounts (
CREATE TABLE IF NOT EXISTS accounts (
id INTEGER PRIMARY KEY AUTOINCREMENT ,
id INTEGER PRIMARY KEY AUTOINCREMENT ,
dateCreated TEXT NOT NULL ,
dateCreated TEXT NOT NULL ,
derivationPath TEXT ,
derivationPath TEXT ,
did TEXT NOT NULL UNIQUE , -- UNIQUE constraint for foreign key support
did TEXT NOT NULL ,
identityEncrBase64 TEXT , -- encrypted & base64 - encoded
identityEncrBase64 TEXT , -- encrypted & base64 - encoded
mnemonicEncrBase64 TEXT , -- encrypted & base64 - encoded
mnemonicEncrBase64 TEXT , -- encrypted & base64 - encoded
passkeyCredIdHex TEXT ,
passkeyCredIdHex TEXT ,
@ -106,8 +102,7 @@ const MIGRATIONS = [
profileImageUrl TEXT ,
profileImageUrl TEXT ,
publicKeyBase64 TEXT ,
publicKeyBase64 TEXT ,
seesMe BOOLEAN ,
seesMe BOOLEAN ,
registered BOOLEAN ,
registered BOOLEAN
iViewContent BOOLEAN DEFAULT TRUE
) ;
) ;
CREATE INDEX IF NOT EXISTS idx_contacts_did ON contacts ( did ) ;
CREATE INDEX IF NOT EXISTS idx_contacts_did ON contacts ( did ) ;
@ -122,12 +117,23 @@ const MIGRATIONS = [
id TEXT PRIMARY KEY ,
id TEXT PRIMARY KEY ,
blobB64 TEXT
blobB64 TEXT
) ;
) ;
` ,
} ,
{
name : "002_add_iViewContent_to_contacts" ,
sql : `
ALTER TABLE contacts ADD COLUMN iViewContent BOOLEAN DEFAULT TRUE ;
` ,
} ,
{
name : "003_active_identity_and_seed_backup" ,
sql : `
-- Enable foreign key constraints for data integrity
PRAGMA foreign_keys = ON ;
-- Add UNIQUE constraint to accounts . did for foreign key support
CREATE UNIQUE INDEX IF NOT EXISTS idx_accounts_did_unique ON accounts ( did ) ;
CREATE TABLE IF NOT EXISTS migrations (
name TEXT PRIMARY KEY ,
applied_at TEXT NOT NULL DEFAULT ( datetime ( 'now' ) )
) ;
-- Create active_identity table with foreign key constraint
-- Create active_identity table with foreign key constraint
CREATE TABLE IF NOT EXISTS active_identity (
CREATE TABLE IF NOT EXISTS active_identity (
id INTEGER PRIMARY KEY CHECK ( id = 1 ) ,
id INTEGER PRIMARY KEY CHECK ( id = 1 ) ,
@ -137,12 +143,20 @@ const MIGRATIONS = [
) ;
) ;
-- Add performance indexes
-- Add performance indexes
CREATE INDEX IF NOT EXISTS idx_active_identity_activeDid ON active_identity ( activeDid ) ;
CREATE UNIQUE INDEX IF NOT EXISTS idx_active_identity_single_record ON active_identity ( id ) ;
CREATE UNIQUE INDEX IF NOT EXISTS idx_active_identity_single_record ON active_identity ( id ) ;
-- Seed singleton row
-- Seed singleton row
INSERT INTO active_identity ( id , activeDid , lastUpdated ) VALUES ( 1 , NULL , datetime ( 'now' ) ) ;
INSERT INTO active_identity ( id , activeDid , lastUpdated ) VALUES ( 1 , NULL , datetime ( 'now' ) ) ;
` ,
-- Add hasBackedUpSeed field to settings ( from registration - prompt - parity )
ALTER TABLE settings ADD COLUMN hasBackedUpSeed BOOLEAN DEFAULT FALSE ;
-- Create migrations tracking table
CREATE TABLE IF NOT EXISTS migrations (
name TEXT PRIMARY KEY ,
applied_at TEXT NOT NULL DEFAULT ( datetime ( 'now' ) )
) ;
` ,
} ,
} ,
] ;
] ;