0007_activity_farm_settings_section.sql (1412B)
1 ALTER TABLE activity_events RENAME TO activity_events_old; 2 3 CREATE TABLE activity_events ( 4 activity_event_id TEXT PRIMARY KEY, 5 recorded_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), 6 event_kind TEXT NOT NULL, 7 settings_section TEXT, 8 settings_preference TEXT, 9 preference_enabled INTEGER, 10 CHECK ( 11 event_kind IN ( 12 'home_opened', 13 'settings_opened', 14 'settings_section_selected', 15 'settings_preference_updated' 16 ) 17 ), 18 CHECK ( 19 settings_section IS NULL 20 OR settings_section IN ('account', 'farm', 'settings', 'about') 21 ), 22 CHECK ( 23 settings_preference IS NULL 24 OR settings_preference IN ( 25 'allow_relay_connections', 26 'use_media_servers', 27 'use_nip05', 28 'launch_at_login' 29 ) 30 ), 31 CHECK (preference_enabled IS NULL OR preference_enabled IN (0, 1)) 32 ); 33 34 INSERT INTO activity_events ( 35 activity_event_id, 36 recorded_at, 37 event_kind, 38 settings_section, 39 settings_preference, 40 preference_enabled 41 ) 42 SELECT 43 activity_event_id, 44 recorded_at, 45 event_kind, 46 settings_section, 47 settings_preference, 48 preference_enabled 49 FROM activity_events_old; 50 51 DROP TABLE activity_events_old; 52 53 CREATE INDEX activity_events_recorded_at_idx 54 ON activity_events(recorded_at DESC, activity_event_id DESC);