Use the store's tables in an already-open database, creating any that are missing.
(db: Arc<Database>)
| 349 | /// Use the store's tables in an already-open database, creating any that |
| 350 | /// are missing. |
| 351 | pub fn from_database(db: Arc<Database>) -> RedbStoreResult<Self> { |
| 352 | atomic_core::pristine::schema::check_schema_version(&db.begin_read()?) |
| 353 | .map_err(|error| RedbStoreError::Corrupt(error.to_string()))?; |
| 354 | { |
| 355 | let txn = db.begin_write()?; |
| 356 | { |
| 357 | let _ = txn.open_table(tables::CHANGE_META)?; |
| 358 | let _ = txn.open_table(tables::CHANGE_GRAPH)?; |
| 359 | let _ = txn.open_table(tables::CHANGE_SEMANTIC)?; |
| 360 | let _ = txn.open_table(tables::CONTENT_CHUNKS)?; |
| 361 | let _ = txn.open_table(tables::CHANGE_CHUNKS)?; |
| 362 | let _ = txn.open_table(tables::CHANGE_UNHASHED)?; |
| 363 | let _ = txn.open_table(tables::CHANGE_SIGNATURES)?; |
| 364 | Self::initialize_provenance_tables(&txn)?; |
| 365 | let _ = txn.open_table(tables::SESSION_LOG)?; |
| 366 | let _ = txn.open_table(tables::SESSION_LOG_IDS)?; |
| 367 | let _ = txn.open_table(tables::SESSION_LOG_INDEX)?; |
| 368 | } |
| 369 | txn.commit()?; |
| 370 | } |
| 371 | |
| 372 | Ok(Self { db }) |
| 373 | } |
| 374 | |
| 375 | /// Get a reference to the underlying database. |
| 376 | pub(crate) fn db(&self) -> &Database { |
nothing calls this directly
no test coverage detected