From eef7980222e646968c3b3830f4087835b0971d86 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Sat, 24 Apr 2021 23:16:30 +0300 Subject: [PATCH] chore: cosmetic changes --- migra-cli/src/database/migration.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/migra-cli/src/database/migration.rs b/migra-cli/src/database/migration.rs index f12803a..e6b1657 100644 --- a/migra-cli/src/database/migration.rs +++ b/migra-cli/src/database/migration.rs @@ -61,10 +61,15 @@ impl MigrationManager { pub fn is_migrations_table_not_found(error: D) -> bool { let error_message = error.to_string(); - // Postgres error - error_message.contains(r#"relation "migrations" does not exist"#) - // MySQL error - || error_message.contains("ERROR 1146 (42S02)") + fn is_postgres_error(error_message: &str) -> bool { + error_message.contains("relation") && error_message.ends_with("does not exist") + } + + fn is_mysql_error(error_message: &str) -> bool { + error_message.contains("ERROR 1146 (42S02)") + } + + is_postgres_error(&error_message) || is_mysql_error(&error_message) } pub trait ManageMigration {