Add versioned script library, reconcile permit refusals and compact helper captures
This commit is contained in:
@@ -1038,6 +1038,20 @@ fn initialize(db: &Connection, binding: &Binding) -> Result<()> {
|
||||
CREATE TABLE IF NOT EXISTS helper_sync_rows(grant_id TEXT PRIMARY KEY,revision INTEGER NOT NULL,fingerprint TEXT NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS helper_sync_captures(checkpoint INTEGER PRIMARY KEY,snapshot BLOB NOT NULL,fingerprint TEXT NOT NULL,captured_at TEXT NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS helper_sync_decisions(decision_id TEXT PRIMARY KEY,checkpoint INTEGER NOT NULL,response BLOB NOT NULL,request BLOB NOT NULL,fingerprint TEXT NOT NULL);")?;
|
||||
let legacy_captures: bool = db.query_row(
|
||||
"SELECT EXISTS(SELECT 1 FROM sqlite_schema WHERE type='table' AND name='helper_sync_captures')",
|
||||
[], |row| row.get(0),
|
||||
)?;
|
||||
if legacy_captures {
|
||||
// initialize runs under the snapshot transaction; savepoint also makes
|
||||
// the schema change atomic for callers that initialize independently.
|
||||
db.execute_batch("SAVEPOINT helper_capture_schema")?;
|
||||
if let Err(error) = db.execute_batch(include_str!("helper_capture_storage.sql")) {
|
||||
db.execute_batch("ROLLBACK TO helper_capture_schema; RELEASE helper_capture_schema")?;
|
||||
return Err(error.into());
|
||||
}
|
||||
db.execute_batch("RELEASE helper_capture_schema")?;
|
||||
}
|
||||
let binding_hash = hash(&serde_json::to_vec(binding)?);
|
||||
db.execute(
|
||||
"INSERT OR IGNORE INTO helper_sync_meta(id,journal_id,binding_sha256) VALUES(1,?1,?2)",
|
||||
|
||||
Reference in New Issue
Block a user