/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)
| 138 | /// |
| 139 | /// TODO: Propagate more of these errors instead of panicking |
| 140 | pub 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 |
| 162 | pub const fn health() {} |