agentmux_srv_core/backend/storage/
builtin_seeds.rs1use rusqlite::params;
9
10use super::error::StoreError;
11use super::store::Store;
12
13const SCHEMA: &str = "CREATE TABLE IF NOT EXISTS db_builtin_seeds (
14 key TEXT PRIMARY KEY,
15 seeded_at INTEGER NOT NULL DEFAULT 0
16 );";
17
18impl Store {
19 pub fn builtin_seed_done(&self, key: &str) -> Result<bool, StoreError> {
21 let conn = self.conn.lock().unwrap();
22 conn.execute_batch(SCHEMA)?;
23 let n: i64 = conn.query_row("SELECT COUNT(*) FROM db_builtin_seeds WHERE key = ?1", params![key], |r| r.get(0))?;
24 Ok(n > 0)
25 }
26
27 pub fn builtin_seed_mark(&self, key: &str, now_ms: i64) -> Result<(), StoreError> {
29 let conn = self.conn.lock().unwrap();
30 conn.execute_batch(SCHEMA)?;
31 conn.execute("INSERT OR IGNORE INTO db_builtin_seeds (key, seeded_at) VALUES (?1, ?2)", params![key, now_ms])?;
32 Ok(())
33 }
34}