Skip to content

Commit fa0dcd6

Browse files
committed
Included StructureSafe feature, fixed tokio runtime flavor
1 parent ce47be7 commit fa0dcd6

5 files changed

Lines changed: 17 additions & 9 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ regex = { version = "~1" }
4343
once_cell = { version = "~1" }
4444

4545
# Runtime
46-
tokio = { version = ">=1.23.1", features = ["macros"], optional = true }
46+
tokio = { version = ">=1.23.1", features = ["macros", "rt"], optional = true }
4747

4848
# Enum simplification
4949
strum = { version = "~0.25" }

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod migrate;
1111
pub mod squash_migrations;
1212
pub mod utils;
1313

14-
#[tokio::main]
14+
#[tokio::main(flavor = "current_thread")]
1515
async fn main() -> anyhow::Result<()> {
1616
let cli: Cli = Cli::parse();
1717

src/migrate/sql_builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ pub async fn migration_to_sql<'a>(
114114
mysql,
115115
postgres,
116116
sqlite,
117+
..
117118
} => match db_impl {
118119
DBImpl::SQLite => {
119120
execute_statement(tx, sqlite.clone(), Vec::new(), do_log).await?;

src/utils/migrations.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,21 @@ pub fn convert_migrations_to_internal_models(
239239
}
240240
Ok(())
241241
}
242-
Operation::RawSQL { .. } => Err(anyhow!(
243-
r#"RawSQL migration found!
242+
Operation::RawSQL { structure_safe, .. } => {
243+
if *structure_safe {
244+
Ok(())
245+
} else {
246+
Err(anyhow!(
247+
r#"RawSQL migration without StructureSafe flag found!
244248
245249
Can not proceed to generate migrations as the current database state can not be determined anymore!
246250
You can still write migrations with all available operations yourself.
247251
248-
To use the make-migrations feature again, delete all RawSQL operations."#
249-
)),
252+
To use the make-migrations feature again, check that all RawSQL operations don't change any
253+
structure and mark them as StructureSafe or delete all RawSQL operations."#
254+
))
255+
}
256+
}
250257
})
251258
});
252259

src/utils/re.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ pub struct Regexes {
99
}
1010

1111
pub static RE: Lazy<Regexes> = Lazy::new(|| Regexes {
12-
numeric_only: Regex::new(r#"^\d+$"#).unwrap(),
12+
numeric_only: Regex::new(r"^\d+$").unwrap(),
1313
forbidden_character: Regex::new(r#"[^a-zA-Z0-9_]"#).unwrap(),
14-
migration_allowed_comment: Regex::new(r#"^\w+$"#).unwrap(),
15-
migration_allowed_name: Regex::new(r#"^[0-9]{4}_\w+\.toml$"#).unwrap(),
14+
migration_allowed_comment: Regex::new(r"^\w+$").unwrap(),
15+
migration_allowed_name: Regex::new(r"^[0-9]{4}_\w+\.toml$").unwrap(),
1616
});

0 commit comments

Comments
 (0)