From 5a9e68816eed1a0eed45a72f6555aca55313e99a Mon Sep 17 00:00:00 2001 From: Saurav Sharma Date: Sun, 12 Jan 2025 20:17:59 +0545 Subject: [PATCH] docs: fix missing self in down migration example of readme fixes #41 Signed-off-by: Saurav Sharma --- README.MD | 2 +- src/migrator/mod.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.MD b/README.MD index 8289518..1b55fc6 100644 --- a/README.MD +++ b/README.MD @@ -63,7 +63,7 @@ impl Operation for FirstOperation { } // down migration runs down migration - async fn down(connection: &mut sqlx::PgConnection) -> Result<(), Error> { + async fn down(&self, connection: &mut sqlx::PgConnection) -> Result<(), Error> { sqlx::query("DROP TABLE sample").execute(connection).await?; Ok(()) } diff --git a/src/migrator/mod.rs b/src/migrator/mod.rs index 043a89b..bd3ad60 100644 --- a/src/migrator/mod.rs +++ b/src/migrator/mod.rs @@ -870,10 +870,11 @@ where match plan.plan_type { PlanType::Apply => { tracing::debug!("applying {} : {}", migration.app(), migration.name()); + let operations = migration.operations(); if migration.is_atomic() { let mut transaction = connection.begin().await?; if !plan.fake { - for operation in migration.operations() { + for operation in operations { operation.up(&mut transaction).await?; } } @@ -882,7 +883,7 @@ where transaction.commit().await?; } else { if !plan.fake { - for operation in migration.operations() { + for operation in operations { operation.up(connection).await?; } }