(db: C, f: F)
| 250 | } |
| 251 | |
| 252 | async fn exec_with_connection<'c, C, F>(db: C, f: F) -> Result<(), DbErr> |
| 253 | where |
| 254 | C: IntoSchemaManagerConnection<'c>, |
| 255 | F: for<'b> Fn( |
| 256 | &'b SchemaManager<'_>, |
| 257 | ) -> Pin<Box<dyn Future<Output = Result<(), DbErr>> + Send + 'b>>, |
| 258 | { |
| 259 | let db = db.into_schema_manager_connection(); |
| 260 | |
| 261 | match db.get_database_backend() { |
| 262 | DbBackend::Postgres => { |
| 263 | let transaction = db.begin().await?; |
| 264 | let manager = SchemaManager::new(&transaction); |
| 265 | f(&manager).await?; |
| 266 | transaction.commit().await |
| 267 | } |
| 268 | DbBackend::MySql | DbBackend::Sqlite => { |
| 269 | let manager = SchemaManager::new(db); |
| 270 | f(&manager).await |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | async fn exec_fresh<M>(manager: &SchemaManager<'_>) -> Result<(), DbErr> |
| 276 | where |
nothing calls this directly
no test coverage detected