text: CREATE TABLE profiles (
    id INTEGER PRIMARY KEY NOT NULL,
    url TEXT,
    createdAt INTEGER DEFAULT (strftime('%s', 'now'))
  );
  
  CREATE TABLE archives (
    profileId INTEGER NOT NULL,
    key TEXT NOT NULL,
    localPath TEXT,
    isSaved INTEGER,
    createdAt INTEGER DEFAULT (strftime('%s', 'now')),
    autoDownload INTEGER DEFAULT 1,
    autoUpload INTEGER DEFAULT 1,
    networked INTEGER DEFAULT 1,
    expiresAt INTEGER
  );
  
  CREATE TABLE archives_meta (
    key TEXT PRIMARY KEY,
    title TEXT,
    description TEXT,
    forkOf TEXT,
    createdByUrl TEXT,
    createdByTitle TEXT,
    mtime INTEGER,
    metaSize INTEGER,
    stagingSize INTEGER,
    isOwner INTEGER,
    lastAccessTime INTEGER DEFAULT 0,
    lastLibraryAccessTime INTEGER DEFAULT 0
  );
  
  CREATE TABLE archives_meta_type (
    key TEXT,
    type TEXT
  );
  
  CREATE TABLE bookmarks (
    profileId INTEGER,
    url TEXT NOT NULL,
    title TEXT,
    pinned INTEGER,
    createdAt INTEGER DEFAULT (strftime('%s', 'now')),
    tags TEXT,
    notes TEXT,
  
    PRIMARY KEY (profileId, url),
    FOREIGN KEY (profileId) REFERENCES profiles (id) ON DELETE CASCADE
  );
  
  CREATE TABLE visits (
    profileId INTEGER,
    url TEXT NOT NULL,
    title TEXT NOT NULL,
    ts INTEGER NOT NULL,
  
    FOREIGN KEY (profileId) REFERENCES profiles (id) ON DELETE CASCADE
  );
  CREATE INDEX visits_url ON visits (url);
  
  CREATE TABLE visit_stats (
    url TEXT NOT NULL,
    num_visits INTEGER,
    last_visit_ts INTEGER
  );
  
  CREATE VIRTUAL TABLE visit_fts USING fts4 (url, title);
  CREATE UNIQUE INDEX visits_stats_url ON visit_stats (url);
  
  -- list of the user's installed apps
  CREATE TABLE apps (
    profileId INTEGER NOT NULL,
    name TEXT NOT NULL,
    url TEXT,
    updatedAt INTEGER DEFAULT (strftime('%s', 'now')),
    createdAt INTEGER DEFAULT (strftime('%s', 'now')),
   
    PRIMARY KEY (profileId, name),
    FOREIGN KEY (profileId) REFERENCES profiles (id) ON DELETE CASCADE
  );
  
  -- log of the user's app installations
  CREATE TABLE apps_log (
    profileId INTEGER NOT NULL,
    name TEXT NOT NULL,
    url TEXT,
    ts INTEGER DEFAULT (strftime('%s', 'now')),
   
    FOREIGN KEY (profileId) REFERENCES profiles (id) ON DELETE CASCADE
  );
  
  CREATE TABLE workspaces (
    profileId INTEGER NOT NULL,
    name TEXT NOT NULL,
    localFilesPath TEXT,
    publishTargetUrl TEXT,
    createdAt INTEGER DEFAULT (strftime('%s', 'now')),
    updatedAt INTEGER DEFAULT (strftime('%s', 'now')),
  
    PRIMARY KEY (profileId, name),
    FOREIGN KEY (profileId) REFERENCES profiles (id) ON DELETE CASCADE
  );
  
  -- default profile
  INSERT INTO profiles (id) VALUES (0);
  
  -- default bookmarks
  INSERT INTO bookmarks (profileId, title, url, pinned) VALUES (0, 'Beaker Home', 'dat://beakerbrowser.com', 1);
  INSERT INTO bookmarks (profileId, title, url, pinned) VALUES (0, 'Dat Project', 'dat://datproject.org', 1);
  INSERT INTO bookmarks (profileId, title, url, pinned) VALUES (0, '@BeakerBrowser', 'https://twitter.com/beakerbrowser', 1);
  INSERT INTO bookmarks (profileId, title, url, pinned) VALUES (0, 'Hashbase', 'https://hashbase.io', 1);
  INSERT INTO bookmarks (profileId, title, url, pinned) VALUES (0, 'Documentation', 'dat://beakerbrowser.com/docs', 1);
  INSERT INTO bookmarks (profileId, title, url, pinned) VALUES (0, 'Report an issue', 'https://github.com/beakerbrowser/beaker/issues', 1);
  INSERT INTO bookmarks (profileId, title, url, pinned) VALUES (0, 'Explore the p2p Web', 'dat://taravancil.com/explore-the-p2p-web.md', 1);
  INSERT INTO bookmarks (profileId, title, url, pinned) VALUES (0, 'Support Beaker', 'https://opencollective.com/beaker', 1);
  
  PRAGMA user_version = 14;
  