From 3e347d4dcb73758b3ebd1a5064e06e844fbea9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Mon, 5 Jul 2021 23:40:09 +0100 Subject: [PATCH] update mysql and mysql_async deps --- .circleci/config.yml | 4 +- refinery/tests/mysql.rs | 95 +++++++++++++++++------------ refinery_core/Cargo.toml | 4 +- refinery_core/src/drivers/config.rs | 3 +- 4 files changed, 63 insertions(+), 43 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e642f852..439c1ee5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,10 +24,10 @@ orbs: parameters: stable: type: string - default: "1.51" + default: "1.53" previous: type: string - default: "1.50" + default: "1.52" nightly: type: string default: "rustlang/rust:nightly" diff --git a/refinery/tests/mysql.rs b/refinery/tests/mysql.rs index bbe82562..ad13f8cc 100644 --- a/refinery/tests/mysql.rs +++ b/refinery/tests/mysql.rs @@ -66,8 +66,9 @@ mod mysql { } fn clean_database() { - let mut conn = - mysql::Conn::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = + mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let mut conn = mysql::Conn::new(opts).unwrap(); "DROP DATABASE refinery_test".run(&mut conn).unwrap(); "CREATE DATABASE refinery_test".run(conn).unwrap(); @@ -87,8 +88,9 @@ mod mysql { #[test] fn report_contains_applied_migrations() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); let report = embedded::migrations::runner().run(&mut conn).unwrap(); @@ -117,8 +119,9 @@ mod mysql { #[test] fn embedded_creates_migration_table() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); embedded::migrations::runner().run(&mut conn).unwrap(); for row in "SELECT table_name FROM information_schema.tables WHERE table_name='refinery_schema_history'".run(conn).unwrap() @@ -132,8 +135,9 @@ mod mysql { #[test] fn embedded_creates_migration_table_grouped_transaction() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); embedded::migrations::runner() .set_grouped(false) @@ -151,8 +155,9 @@ mod mysql { #[test] fn embedded_applies_migration() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); embedded::migrations::runner().run(&mut conn).unwrap(); @@ -172,8 +177,9 @@ mod mysql { #[test] fn embedded_applies_migration_grouped_transaction() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); embedded::migrations::runner() @@ -197,8 +203,9 @@ mod mysql { #[test] fn embedded_updates_schema_history() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); embedded::migrations::runner().run(&mut conn).unwrap(); @@ -212,8 +219,9 @@ mod mysql { #[test] fn embedded_updates_schema_history_grouped_transaction() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); embedded::migrations::runner() @@ -232,8 +240,9 @@ mod mysql { #[test] fn embedded_updates_to_last_working_if_not_grouped() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); let result = broken::migrations::runner().run(&mut conn); @@ -287,8 +296,9 @@ mod mysql { #[test] fn mod_creates_migration_table() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); mod_migrations::runner().run(&mut conn).unwrap(); for row in "SELECT table_name FROM information_schema.tables WHERE table_name='refinery_schema_history'".run(conn).unwrap() @@ -302,8 +312,9 @@ mod mysql { #[test] fn mod_applies_migration() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); mod_migrations::runner().run(&mut conn).unwrap(); @@ -323,8 +334,9 @@ mod mysql { #[test] fn mod_updates_schema_history() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); mod_migrations::runner().run(&mut conn).unwrap(); @@ -339,8 +351,9 @@ mod mysql { #[test] fn gets_applied_migrations() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); embedded::migrations::runner().run(&mut conn).unwrap(); @@ -369,8 +382,9 @@ mod mysql { #[test] fn applies_new_migration() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); embedded::migrations::runner().run(&mut conn).unwrap(); @@ -390,8 +404,9 @@ mod mysql { #[test] fn migrates_to_target_migration() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); let report = embedded::migrations::runner() @@ -424,8 +439,9 @@ mod mysql { #[test] fn migrates_to_target_migration_grouped() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); let report = embedded::migrations::runner() @@ -458,8 +474,9 @@ mod mysql { #[test] fn aborts_on_missing_migration_on_filesystem() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); mod_migrations::runner().run(&mut conn).unwrap(); @@ -486,8 +503,9 @@ mod mysql { #[test] fn aborts_on_divergent_migration() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); mod_migrations::runner().run(&mut conn).unwrap(); @@ -515,8 +533,9 @@ mod mysql { #[test] fn aborts_on_missing_migration_on_database() { run_test(|| { - let pool = - mysql::Pool::new("mysql://refinery:root@localhost:3306/refinery_test").unwrap(); + let opts = mysql::Opts::from_url("mysql://refinery:root@localhost:3306/refinery_test") + .unwrap(); + let pool = mysql::Pool::new(opts).unwrap(); let mut conn = pool.get_conn().unwrap(); missing::migrations::runner().run(&mut conn).unwrap(); diff --git a/refinery_core/Cargo.toml b/refinery_core/Cargo.toml index 0a1656c5..94218e4e 100644 --- a/refinery_core/Cargo.toml +++ b/refinery_core/Cargo.toml @@ -28,9 +28,9 @@ walkdir = "2.3.1" rusqlite = {version = ">= 0.23, < 0.26", optional = true} postgres = {version = "0.19", optional = true} -mysql = {version = "20", optional = true} tokio-postgres = { version = "0.7", optional = true } -mysql_async = { version = "0.26", optional = true } +mysql = { version = "21.0.0", optional = true } +mysql_async = { version = "0.28.0", optional = true } tokio = { version = "1.0", features = ["full"], optional = true } diff --git a/refinery_core/src/drivers/config.rs b/refinery_core/src/drivers/config.rs index c5b4d975..e0c5865e 100644 --- a/refinery_core/src/drivers/config.rs +++ b/refinery_core/src/drivers/config.rs @@ -56,7 +56,8 @@ macro_rules! with_connection { cfg_if::cfg_if! { if #[cfg(feature = "mysql")] { let url = build_db_url("mysql", &$config); - let conn = mysql::Conn::new(&url).migration_err("could not connect to database", None)?; + let opts = mysql::Opts::from_url(&url).migration_err("could not parse url", None)?; + let conn = mysql::Conn::new(opts).migration_err("could not connect to database", None)?; $op(conn) } else { panic!("tried to migrate from config for a mysql database, but feature mysql not enabled!");