diff --git a/sqlx-cli/src/migrate.rs b/sqlx-cli/src/migrate.rs index 54a8c876..f73aa1c3 100644 --- a/sqlx-cli/src/migrate.rs +++ b/sqlx-cli/src/migrate.rs @@ -157,7 +157,7 @@ pub async fn revert(migration_source: &str, uri: &str, dry_run: bool) -> anyhow: for migration in migrator.iter().rev() { if !migration.migration_type.is_down_migration() { // Skipping non down migration - // This will skip any standard or up migration file + // This will skip any simple or up migration file continue; } if migration.version > version { diff --git a/sqlx-macros/src/migrate.rs b/sqlx-macros/src/migrate.rs index 70e55675..9b0de234 100644 --- a/sqlx-macros/src/migrate.rs +++ b/sqlx-macros/src/migrate.rs @@ -1,12 +1,29 @@ use proc_macro2::TokenStream; use quote::{quote, ToTokens, TokenStreamExt}; use sha2::{Digest, Sha384}; +use sqlx_core::migrate::MigrationType; use std::fs; use syn::LitStr; +pub struct QuotedMigrationType(MigrationType); + +impl ToTokens for QuotedMigrationType { + fn to_tokens(&self, tokens: &mut TokenStream) { + let ts = match self.0 { + MigrationType::Simple => quote! { sqlx::migrate::MigrationType::Simple }, + MigrationType::ReversibleUp => quote! { sqlx::migrate::MigrationType::ReversibleUp }, + MigrationType::ReversibleDown => { + quote! { sqlx::migrate::MigrationType::ReversibleDown } + } + }; + tokens.append_all(ts.into_iter()); + } +} + struct QuotedMigration { version: i64, description: String, + migration_type: QuotedMigrationType, sql: String, checksum: Vec, } @@ -16,6 +33,7 @@ impl ToTokens for QuotedMigration { let QuotedMigration { version, description, + migration_type, sql, checksum, } = &self; @@ -24,6 +42,7 @@ impl ToTokens for QuotedMigration { sqlx::migrate::Migration { version: #version, description: std::borrow::Cow::Borrowed(#description), + migration_type: #migration_type, sql: std::borrow::Cow::Borrowed(#sql), checksum: std::borrow::Cow::Borrowed(&[ #(#checksum),* @@ -59,9 +78,10 @@ pub(crate) fn expand_migrator_from_dir(dir: LitStr) -> crate::Result crate::Result