MCPcopy Create free account
hub / github.com/Wulf/create-rust-app / migrate_db

Function migrate_db

crates/create-rust-app/src/dev/controller.rs:140–159  ·  view source on GitHub ↗

/db/migrate performs any pending migrations # Panics cannot connect to the database cannot find the migrations directory cannot run the migrations TODO: Propagate more of these errors instead of panicking

(db: &Database)

Source from the content-addressed store, hash-verified

138///
139/// TODO: Propagate more of these errors instead of panicking
140pub fn migrate_db(db: &Database) -> Result<()> {
141 let mut db = db.pool.clone().get().unwrap();
142
143 let source = FileBasedMigrations::find_migrations_directory().unwrap();
144 let has_pending_migrations =
145 MigrationHarness::has_pending_migration(&mut db, source.clone()).unwrap();
146
147 if !has_pending_migrations {
148 return Ok(());
149 }
150
151 let op = MigrationHarness::run_pending_migrations(&mut db, source);
152 match op {
153 Ok(_) => Ok(()),
154 Err(err) => {
155 println!("{err:#?}");
156 bail!(err)
157 }
158 }
159}
160
161/// /health
162pub const fn health() {}

Callers 1

handle_socketFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected