cedros_data/store/migrate.rs
1use crate::error::Result;
2
3use super::CedrosData;
4
5impl CedrosData {
6 /// Run database migrations.
7 ///
8 /// `ignore_missing = true` so the migrator tolerates foreign entries
9 /// in `_sqlx_migrations` from other packages sharing the same database.
10 ///
11 /// `locking = false` avoids acquiring a session-level `pg_advisory_lock`
12 /// that would leak on failure and block all subsequent migrations.
13 pub async fn migrate(&self) -> Result<()> {
14 let mut migrator = sqlx::migrate!("./migrations");
15 migrator.set_ignore_missing(true);
16 migrator.set_locking(false);
17 migrator.run(self.pool()).await?;
18 Ok(())
19 }
20}