1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Storage backend bootstrap helpers.
//!
//! Centralises the open-then-migrate sequence each deployment mode
//! runs at startup. Local mode opens a SQLite file at the configured
//! path; remote mode connects to PostgreSQL. In both cases the helper
//! returns the backend already type-erased as `Arc<dyn StorageBackend>`
//! so call sites never depend on the concrete driver type.
//!
//! Introduced by Epic 18 Story S-I.1 (AAASM-1859); consumed by the
//! Local/Remote boot paths in subsequent commits of the same Story.
use Path;
use Arc;
use ;
/// Open a SQLite-backed [`StorageBackend`] at `path` and apply pending
/// schema migrations.
///
/// `path`'s parent directories are assumed to exist — local mode
/// guarantees this via `ensure_storage_parent` before calling here.
///
/// Returns the backend already wrapped in `Arc<dyn StorageBackend>` so
/// the caller can hand it straight to [`crate::AppState::new`].
///
/// # Errors
///
/// Surfaces any [`StorageError`](super::StorageError) raised by the
/// underlying `SqliteBackend::open` or `migrate` calls — typically
/// `ConnectionFailed` (bad path / permissions) or `MigrationFailed`
/// (schema apply error).
pub async
/// Connect to a PostgreSQL-backed [`StorageBackend`] from `config`
/// and apply pending schema migrations.
///
/// Returns the backend already wrapped in `Arc<dyn StorageBackend>`
/// for the same reason as [`open_sqlite_backend`].
///
/// # Errors
///
/// Surfaces `ConnectionFailed` when the database is unreachable and
/// `MigrationFailed` when the schema cannot be brought up to date.
pub async