forge_workspace/store/settings.rs
1//! The retired `settings` table, kept only to drop it.
2//!
3//! Its one row was the `/spinner` override, retired when the spinner left the
4//! core - nothing reads or writes the table now, so there is
5//! nothing to drain before [`drop_table`] removes it.
6//!
7//! The same shape as [`crate::store::model_catalog`], whose test pins the
8//! absent-table behaviour this relies on rather than pinning it twice.
9
10use redb::TableDefinition;
11
12use super::Db;
13
14const SETTINGS: TableDefinition<&str, &[u8]> = TableDefinition::new("settings");
15
16/// Remove the table. Returns whether a table was there to drop. Callers
17/// compact afterwards, because dropping a table reclaims nothing on its own.
18pub fn drop_table(db: &Db) -> anyhow::Result<bool> {
19 let txn = db.database().begin_write()?;
20 // `false` for a store that never held an override, which is not an error:
21 // the boot drops cleanly either way.
22 let dropped = txn.delete_table(SETTINGS)?;
23 txn.commit()?;
24 Ok(dropped)
25}