···327327 completed INTEGER NOT NULL DEFAULT 0
328328 );
329329 SELECT crsql_as_crr('todos');
330330+331331+ CREATE TABLE IF NOT EXISTS metadata (
332332+ key TEXT PRIMARY KEY NOT NULL,
333333+ value TEXT,
334334+ updated_at TEXT
335335+ );
336336+ SELECT crsql_as_crr('metadata');
330337 CREATE VIEW IF NOT EXISTS active_todos AS
331338 SELECT
332339 id,
···390397 FROM todos
391398 WHERE completed = 0;
392399 `);
400400+401401+ // Check if onboarding was already done and insert tasks if not
402402+ const onboardingComplete = await db.execA("SELECT value FROM metadata WHERE key = 'onboarding_completed'");
403403+ if (onboardingComplete.length === 0) {
404404+ console.log("Onboarding not completed, inserting onboarding tasks...");
405405+ await db.exec(`
406406+ INSERT INTO todos (id, description, project, tags, due, wait, priority, urgency, completed) VALUES
407407+ (x'00000000000000000000000000000001', 'Create your first task, with the + icon', 'onboarding', '["tutorial"]', '', '', '', 0, 0),
408408+ (x'00000000000000000000000000000002', 'Use attributes like +work or #chores and filter tasks with the search bar', 'onboarding', '["tutorial"]', '', '', '', 0, 0),
409409+ (x'00000000000000000000000000000003', 'Add due dates @2025-01-22 and mark urgent items with !! priority', 'onboarding', '["workflow"]', '', '', '', 0, 0),
410410+ (x'00000000000000000000000000000004', 'Single tap to select, double-tap to edit tasks, swipe right to complete them, try multiple selections!', 'onboarding', '["workflow"]', '', '', '', 0, 0),
411411+ (x'00000000000000000000000000000005', 'Switch rooms in the sidebar for separate workspaces', 'onboarding', '["rooms"]', '', '', '', 0, 0);
412412+413413+ INSERT INTO metadata (key, value, updated_at) VALUES
414414+ ('onboarding_completed', 'true', datetime('now'));
415415+ `);
416416+ }
417417+393418 const rx = tblrx(db);
394419395420 // Register the database context