MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / exec_with_connection

Function exec_with_connection

sea-orm-migration/src/migrator.rs:252–273  ·  view source on GitHub ↗
(db: C, f: F)

Source from the content-addressed store, hash-verified

250}
251
252async fn exec_with_connection<'c, C, F>(db: C, f: F) -> Result<(), DbErr>
253where
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
275async fn exec_fresh<M>(manager: &SchemaManager<'_>) -> Result<(), DbErr>
276where

Callers

nothing calls this directly

Calls 5

newFunction · 0.50
get_database_backendMethod · 0.45
beginMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected