Skip to main content

browser_control/registry/
schema.rs

1//! SQLite schema for the browser registry.
2
3use anyhow::{Context, Result};
4
5const SCHEMA: &str = r#"
6CREATE TABLE IF NOT EXISTS browsers (
7  name        TEXT PRIMARY KEY,
8  kind        TEXT NOT NULL,
9  engine      TEXT NOT NULL,
10  pid         INTEGER NOT NULL,
11  endpoint    TEXT NOT NULL,
12  port        INTEGER NOT NULL,
13  profile_dir TEXT NOT NULL,
14  executable  TEXT NOT NULL,
15  headless    INTEGER NOT NULL,
16  started_at  TEXT NOT NULL
17);
18CREATE INDEX IF NOT EXISTS browsers_kind_started ON browsers(kind, started_at DESC);
19"#;
20
21/// Apply the schema migration. Idempotent.
22pub fn apply(conn: &rusqlite::Connection) -> Result<()> {
23    conn.execute_batch(SCHEMA)
24        .context("applying registry schema")?;
25    Ok(())
26}