From 2af136128a59a245e5d8e72d86e7c1ed56120c87 Mon Sep 17 00:00:00 2001 From: Edward Fitz Abucay <ffimnsr@gmail.com> Date: Thu, 9 Jan 2025 14:23:35 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=95=20Add=20docs=20file=20and=20instal?= =?UTF-8?q?ler=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Edward Fitz Abucay <ffimnsr@gmail.com> --- .env.example | 3 - .mk/vault/app/development/data.asc | 14 + Cargo.lock | 395 +++++++------- Cargo.toml | 5 +- README.md | 26 + clippy.toml | 2 +- docs/.nojekyll | 0 docs/README.md | 169 ++++++ docs/index.html | 22 + install.sh | 501 ++++++++++++++++++ sample_migrations_mysql/.gitkeep | 0 .../0000000000000_initial.sql | 2 +- sample_migrations_sqlite/.gitkeep | 0 .../0000000000000_initial.sql | 6 + src/commander.rs | 34 +- src/lookup.rs | 15 +- src/midas/bin/cli.rs | 55 +- src/midas/bin/main.rs | 2 + src/midas/bin/migrate_main.rs | 1 + 19 files changed, 987 insertions(+), 265 deletions(-) delete mode 100644 .env.example create mode 100644 .mk/vault/app/development/data.asc create mode 100644 docs/.nojekyll create mode 100644 docs/README.md create mode 100644 docs/index.html create mode 100755 install.sh create mode 100644 sample_migrations_mysql/.gitkeep rename {sample_migrations => sample_migrations_mysql}/0000000000000_initial.sql (58%) create mode 100644 sample_migrations_sqlite/.gitkeep create mode 100644 sample_migrations_sqlite/0000000000000_initial.sql diff --git a/.env.example b/.env.example deleted file mode 100644 index 175b25e..0000000 --- a/.env.example +++ /dev/null @@ -1,3 +0,0 @@ -RUST_LOG=info -DATABASE_URL=postgres://postgres:postgres@localhost:5432/test_migration -MIGRATIONS_ROOT=sample_migrations diff --git a/.mk/vault/app/development/data.asc b/.mk/vault/app/development/data.asc new file mode 100644 index 0000000..dcf3d01 --- /dev/null +++ b/.mk/vault/app/development/data.asc @@ -0,0 +1,14 @@ +-----BEGIN PGP MESSAGE----- + +wcBMA8iIaRIRZ40pAQf9GV2xESWEz/QAMLMzgDoLtHus67bOfmcLyN7S/42T/nMG +Cpq1jy7mWjBzwDm28OU9Id6fLJ8i3qmC9dusMOTx92mvM0ul0vw5hILaogqFt3xd +QQnBcJPLXZ20VS+BB9ZtCWXqlkLeRySfo2tPE9OI67/VRug4N4Zkz1xdsi7KAnjW +Wc8PZwItSROSUTcEHgM0b8x/YeJf5yljIYRe6W7ENJ72gDpMcpkYLuyT1wViT3n8 +smOu31kyaK0I7Jjt9gftg1UQpAdVgkpxzvwq5GyCnGdj2/8wFdSIk/G8E87Its9R +Ezm/BSNto68U14rMP302F96EuDNFeErUaaPu3zjuk9KuAb8DTth/IXKGWfY4XHIN +1spVaYhhIKRwQOOz1DIgCmganLVYitKRupvNmrfD3QWwPlvYfjTCL/wzIbzSpSLu +oaZp4T0SEluYbi2/8xexkg9HtcaB296KTAsqR2/XjQugSdZh0kG4WPGJF73sTJA/ +jKdlJz7sbABa+UN96vGYTLe5CEgjN6/3ufuoI/Xgc2s494qJ0emMLW7krukGPTcV +DWmq6/neYn9+I9Us/DGv +=X1fo +-----END PGP MESSAGE----- diff --git a/Cargo.lock b/Cargo.lock index 7a02ceb..a7ef7dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "android-tzdata" @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "arrayvec" @@ -142,13 +142,13 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -186,9 +186,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bigdecimal" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f850665a0385e070b64c38d2354e6c104c8479c59868d1e48a0c13ee2c7a1c1" +checksum = "7f31f3af01c5c65a07985c804d3366560e6fa7883d640a122819b14ec327482c" dependencies = [ "autocfg", "libm", @@ -199,9 +199,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.70.1" +version = "0.71.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" +checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3" dependencies = [ "bitflags", "cexpr", @@ -212,7 +212,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -262,7 +262,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -316,15 +316,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cc" -version = "1.2.1" +version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" dependencies = [ "jobserver", "libc", @@ -354,9 +354,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", @@ -377,18 +377,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.21" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" +checksum = "9560b07a799281c7e0958b9296854d6fafd4c5f31444a7e5bb1ad6dde5ccf1bd" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.21" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" +checksum = "874e0dd3eb68bf99058751ac9712f622e61e6f393a94f7128fa26e3f02f5c7cd" dependencies = [ "anstream", "anstyle", @@ -398,15 +398,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "cmake" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a" +checksum = "c682c223677e0e5b6b7f63a64b9351844c3f1b1678a68b7ee617e30fb082620e" dependencies = [ "cc", ] @@ -448,9 +448,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -479,18 +479,18 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.13" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -507,18 +507,18 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crypto-common" @@ -572,7 +572,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -583,7 +583,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -603,7 +603,7 @@ checksum = "65f152f4b8559c4da5d574bafc7af85454d706b4c5fe8b530d508cacbb6807ea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -646,7 +646,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -675,12 +675,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -703,9 +703,9 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" [[package]] name = "fastrand" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "flate2" @@ -726,9 +726,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" [[package]] name = "foreign-types" @@ -783,7 +783,7 @@ checksum = "e99b8b3c28ae0e84b604c75f721c21dc77afb3706076af5e8216d15fd1deaae3" dependencies = [ "frunk_proc_macro_helpers", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -795,7 +795,7 @@ dependencies = [ "frunk_core", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -807,7 +807,7 @@ dependencies = [ "frunk_core", "frunk_proc_macro_helpers", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -840,7 +840,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -899,9 +899,9 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "hashbrown" @@ -923,9 +923,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "allocator-api2", "equivalent", @@ -947,12 +947,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "hermit-abi" version = "0.4.0" @@ -1106,7 +1100,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -1138,12 +1132,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", - "hashbrown 0.15.1", + "hashbrown 0.15.2", ] [[package]] @@ -1180,7 +1174,7 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" dependencies = [ - "hermit-abi 0.4.0", + "hermit-abi", "libc", "windows-sys 0.52.0", ] @@ -1202,9 +1196,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jobserver" @@ -1217,10 +1211,11 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -1232,15 +1227,15 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.164" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libloading" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", "windows-targets", @@ -1275,9 +1270,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.20" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" +checksum = "df9b68e50e6e0b26f672573834882eb57759f6db9b3be2ea3c35c91188bb4eaa" dependencies = [ "cc", "pkg-config", @@ -1286,15 +1281,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litemap" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "lock_api" @@ -1318,7 +1313,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.15.1", + "hashbrown 0.15.2", ] [[package]] @@ -1348,7 +1343,7 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "midas" -version = "0.7.2" +version = "0.7.3" dependencies = [ "anyhow", "clap", @@ -1367,7 +1362,6 @@ dependencies = [ "serde", "serde_yaml", "tempfile", - "thiserror 2.0.3", "tracing", "tracing-attributes", "tracing-futures", @@ -1383,20 +1377,19 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", ] [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi 0.3.9", "libc", "wasi", "windows-sys 0.52.0", @@ -1440,9 +1433,9 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", "termcolor", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -1478,7 +1471,7 @@ dependencies = [ "sha2", "smallvec", "subprocess", - "thiserror 1.0.69", + "thiserror", "time", "uuid", "zstd", @@ -1562,9 +1555,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.5" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] @@ -1598,7 +1591,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -1670,47 +1663,47 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "phf" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" dependencies = [ "phf_shared", ] [[package]] name = "phf_shared" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ "siphasher", ] [[package]] name = "pin-project" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" +checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" +checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -1726,9 +1719,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "portable-atomic" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "postgres" @@ -1830,14 +1823,14 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] name = "proc-macro2" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307e3004becf10f5a6e0d59d20f3cd28231b0e0827a96cd3e0ce6d14bc1e4bb3" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -1864,9 +1857,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -1909,9 +1902,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ "bitflags", ] @@ -1924,7 +1917,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -2047,28 +2040,28 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" [[package]] name = "rustix" -version = "0.38.41" +version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "ryu" @@ -2118,9 +2111,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.1" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" dependencies = [ "core-foundation-sys", "libc", @@ -2128,29 +2121,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", @@ -2216,9 +2209,9 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "siphasher" -version = "0.3.11" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "slab" @@ -2237,9 +2230,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -2303,9 +2296,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.89" +version = "2.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" +checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a" dependencies = [ "proc-macro2", "quote", @@ -2320,7 +2313,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -2331,12 +2324,13 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" +checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", + "getrandom", "once_cell", "rustix", "windows-sys 0.59.0", @@ -2368,16 +2362,7 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl 1.0.69", -] - -[[package]] -name = "thiserror" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" -dependencies = [ - "thiserror-impl 2.0.3", + "thiserror-impl", ] [[package]] @@ -2388,18 +2373,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] @@ -2414,9 +2388,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.36" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "num-conv", @@ -2433,9 +2407,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" dependencies = [ "num-conv", "time-core", @@ -2453,9 +2427,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" dependencies = [ "tinyvec_macros", ] @@ -2468,9 +2442,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.1" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -2509,9 +2483,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", @@ -2539,9 +2513,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-attributes", @@ -2550,20 +2524,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", @@ -2641,9 +2615,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" [[package]] name = "unicode-ident" @@ -2751,9 +2725,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -2762,24 +2736,23 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2787,28 +2760,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" dependencies = [ "js-sys", "wasm-bindgen", @@ -2959,9 +2932,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "39281189af81c07ec09db316b302a3e67bf9bd7cbf6c820b50e35fee9c2fa980" dependencies = [ "memchr", ] @@ -2989,9 +2962,9 @@ dependencies = [ [[package]] name = "yoke" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", @@ -3001,13 +2974,13 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", "synstructure", ] @@ -3029,27 +3002,27 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] name = "zerofrom" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", "synstructure", ] @@ -3072,7 +3045,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.89", + "syn 2.0.95", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 30d8f7e..76dceab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "midas" -version = "0.7.2" +version = "0.7.3" authors = ["Edward Fitz Abucay <gh:@ffimnsr>"] edition = "2021" readme = "README.md" @@ -25,7 +25,7 @@ name = "cargo-migrate" path = "src/midas/bin/migrate_main.rs" [dependencies] -clap = { version = "4.5", features = ["string"] } +clap = { version = "4.5", features = ["env", "string"] } postgres = "0.19" mysql = "25.0" rusqlite = { version = "0.32", features = ["bundled"] } @@ -40,7 +40,6 @@ url = "2.5" indoc = "2" openssl = { version = "0.10", features = ["vendored"] } prettytable-rs = "0.10.0" -thiserror = "2.0.3" anyhow = "1.0.93" indicatif = "0.17.9" serde = { version = "1.0.215", features = ["derive"] } diff --git a/README.md b/README.md index 0aecaf6..46de49e 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,32 @@ The binary name for midas are `midas` and `cargo-migrate`. Binary for different OS distribution can be downloaded [here](https://github.com/ffimnsr/midas/releases). Linux, macOS, and Windows are supported. +### Install using script + +`midas` runs on most major platforms. If your platform isn't listed below, please [open an issue](https://github.com/ffimnsr/midas-rs/issues/new). + +<details> + <summary>Linux / WSL / MSYS2 / Cygwin / Git Bash</summary> + + > The recommended way to install midas is via the install script: + > + > + > ```sh + > curl -sSfL https://raw.githubusercontent.com/ffimnsr/midas-rs/main/install.sh | sh + > ``` +</details> + +<details> + <summary>BSD / Android</summary> + + > The recommended way to install midas is via the install script: + > + > + > ```sh + > curl -sS https://raw.githubusercontent.com/ffimnsr/midas-rs/main/install.sh | bash + > ``` +</details> + ### From source If you're into **Rust**, then midas can be installed with `cargo`. The minimum supported version of Rust is `1.37.0`. The binaries produce may be bigger than expected as it contains debug symbols. diff --git a/clippy.toml b/clippy.toml index fe7b174..5380202 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,5 +1,5 @@ disallowed-methods = [ - { path = "std::path::Path::display", reason = "incorrect handling of non-Unicode paths, use path.to_utf8() or debug (`{path:?}`) instead" }, + { path = "std::path::Path::display", reason = "incorrect handling of non-Unicode paths, use path.to_utf8() or debug (`{path:?}`) instead" }, ] allow-unwrap-in-tests = true msrv = "1.77.2" diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..46de49e --- /dev/null +++ b/docs/README.md @@ -0,0 +1,169 @@ +# Midas (cargo-migrate) + +[](https://crates.io/crates/midas) +[](https://crates.io/crates/midas) +[](https://github.com/ffimnsr/midas-rs/blob/master/LICENSE-APACHE) +[](https://github.com/ffimnsr/midas-rs/blob/master/.github/workflows/ci.yaml) + + +> So Midas, king of Lydia, swelled at first with pride +> when he found he could transform everything he touched +> to gold; but when he beheld his food grow rigid and his +> drink harden into golden ice then he understood that +> this gift was a bane and in his loathing for gold, cursed +> his prayer. +> - from In Rufinem, Claudian + +Do painless migrations. + +## Supported Database + +- [x] PostgresSQL +- [x] CockroachDB +- [x] MySQL +- [x] MariaDB +- [x] SQLite3 +- [ ] MSSQL +- [ ] Cassandra +- [ ] OracleDB + +## Usage + +### Using CLI + +Here is a sample command line usage of `midas`. + +```shell +# PostgresSQL +midas --database 'postgres://postgres:postgres@localhost:5432/startup' --source migrations up + +# MySQL/MariaDB +midas --database 'mysql://root:mysql@localhost:3306/startup' --source migrations up + +# SQLite +midas --database 'file:///./data.db' --source migrations up +``` + +or you could also use the `cargo migrate` to integrate it on your cargo workflow. + +> **NOTE:** For SQLite use correct URI filenames as stated here: https://www.sqlite.org/c3ref/open.html#urifilenameexamples + +### Using on container + +Here is a basic setup: + +```bash +MIGRATION_DIR=$PWD/migrations +mkdir -p $MIGRATION_DIR +docker run --rm -v $MIGRATION_DIR:/app/migrations ghcr.io/ffimnsr/midas-rs:latest --database 'postgres://postgres:postgres@localhost:5432/startup' --source migrations status +``` + +You can omit the `--source migrations` as the source flag would default to migrations. In case you plan to change the mounted volume migrations path then append the `--source <path/to/migrations>` argument. + +### Command arguments + +The command will execute all **special** (up) SQL migrations files to the database. \ +Here are the available subcommands: + +```shell +create Creates a timestamped migration file +down Remove all applied migrations +drop Drops everything inside the database (NOTE: must have create/drop privilege) +redo Redo the last migration +revert Reverts the last migration +init Setups and creates initial file directory and env +status Checks the status of the migration +up Apply all non-applied migrations +faker Generate fake data for the database (WIP) +setup Setup the database (WIP) +``` + +For more info see `--help`. + +## Installation + +The binary name for midas are `midas` and `cargo-migrate`. + +Binary for different OS distribution can be downloaded [here](https://github.com/ffimnsr/midas/releases). Linux, macOS, and Windows are supported. + +### Install using script + +`midas` runs on most major platforms. If your platform isn't listed below, please [open an issue](https://github.com/ffimnsr/midas-rs/issues/new). + +<details> + <summary>Linux / WSL / MSYS2 / Cygwin / Git Bash</summary> + + > The recommended way to install midas is via the install script: + > + > + > ```sh + > curl -sSfL https://raw.githubusercontent.com/ffimnsr/midas-rs/main/install.sh | sh + > ``` +</details> + +<details> + <summary>BSD / Android</summary> + + > The recommended way to install midas is via the install script: + > + > + > ```sh + > curl -sS https://raw.githubusercontent.com/ffimnsr/midas-rs/main/install.sh | bash + > ``` +</details> + +### From source + +If you're into **Rust**, then midas can be installed with `cargo`. The minimum supported version of Rust is `1.37.0`. The binaries produce may be bigger than expected as it contains debug symbols. + +```bash +cargo install midas +``` + +### For containers + +Docker / Podman installation: + +```bash +# Docker +docker pull ghcr.io/ffimnsr/midas-rs:latest + +# Podman +podman pull ghcr.io/ffimnsr/midas-rs:latest +``` + +### For package managers + +If you're a Debian user (or a user of a Debian derivative like Ubuntu), then midas can be installed using a binary .deb file provided in each midas release. + +```bash +curl -LO https://github.com/ffimnsr/midas-rs/releases/download/0.6.6/midas_0.6.6-1_amd64.deb +sudo dpkg -i midas_0.6.6-1_amd64.deb +``` + +### Manual installation + +Follow the instruction below to install and use `midas` on your system. + +1. Download the binary for your OS distribution [here](https://github.com/ffimnsr/midas/releases). +2. Copy it to your system binary directory (`/usr/local/bin`) or to your userspace binary directory (`$HOME/.local/bin`). + +## What's in the Roadmap + +- [ ] TOML DSL for creating database objects +- [ ] Setup multiple drivers (e.g. MySQL, Sqlite3, etc.) +- [ ] Add functionality for `setup` and `faker` commands. + +## License + +Licensed under either of + +- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) +- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..165445f --- /dev/null +++ b/docs/index.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>Midas (cargo-migrate)</title> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> + <meta name="description" content="Description"> + <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> + <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css"> +</head> +<body> + <div id="app"></div> + <script> + window.$docsify = { + name: 'Midas (cargo-migrate)', + repo: 'ffimnsr/midas-rs' + } + </script> + <!-- Docsify v4 --> + <script src="//cdn.jsdelivr.net/npm/docsify@4"></script> +</body> +</html> diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..52d2f2d --- /dev/null +++ b/install.sh @@ -0,0 +1,501 @@ +#!/bin/sh +# shellcheck shell=dash +# shellcheck disable=SC3043 # Assume `local` extension + +# The official midas installer. +# +# It runs on Unix shells like {a,ba,da,k,z}sh. It uses the common `local` +# extension. Note: Most shells limit `local` to 1 var per line, contra bash. +# This script has been adapted from the official zoxide installer. +# https://github.com/ajeetdsouza/zoxide/blob/main/install.sh + +PACKAGE_NAME="midas" + +main() { + # The version of ksh93 that ships with many illumos systems does not support the "local" + # extension. Print a message rather than fail in subtle ways later on: + if [ "${KSH_VERSION-}" = 'Version JM 93t+ 2010-03-05' ]; then + err 'the installer does not work with this ksh93 version; please try bash' + fi + + set -u + + parse_args "$@" + + local _arch + _arch="${ARCH:-$(ensure get_architecture)}" + assert_nz "${_arch}" "arch" + echo "Detected architecture: ${_arch}" + + local _bin_name + case "${_arch}" in + *windows*) _bin_name="${PACKAGE_NAME}.exe" ;; + *) _bin_name="${PACKAGE_NAME}" ;; + esac + + # Create and enter a temporary directory. + local _tmp_dir + _tmp_dir="$(mktemp -d)" || err "mktemp: could not create temporary directory" + cd "${_tmp_dir}" || err "cd: failed to enter directory: ${_tmp_dir}" + + echo "Temporary directory: ${_tmp_dir}" + + # Download and extract + local _package + _package="$(ensure download_pkg "${_arch}")" + assert_nz "${_package}" "package" + echo "Downloaded package: ${_package}" + case "${_package}" in + *.tar.gz) + need_cmd tar + ensure tar -xf "${_package}" + ;; + *.zip) + need_cmd unzip + ensure unzip -oq "${_package}" + ;; + *) + err "unsupported package format: ${_package}" + ;; + esac + + # Get the filename without the file extension + local _filename_no_ext + _filename_no_ext=$(basename "${_package}" | sed -E 's/\.(tar\.gz|zip)$//') + + # Install binary. + ensure try_sudo mkdir -p -- "${BIN_DIR}" + ensure try_sudo cp -- "${_filename_no_ext}/${_bin_name}" "${BIN_DIR}/${_bin_name}" + ensure try_sudo chmod +x "${BIN_DIR}/${_bin_name}" + echo "Installed ${PACKAGE_NAME} to ${BIN_DIR}" + + # Install manpages. + # ensure try_sudo mkdir -p -- "${MAN_DIR}/man1" + # ensure try_sudo cp -- "man/man1/"* "${MAN_DIR}/man1/" + # echo "Installed manpages to ${MAN_DIR}" + + # Install documentation. + ensure try_sudo mkdir -p -- "${DOC_DIR}/${PACKAGE_NAME}" + ensure try_sudo cp -- "${_filename_no_ext}/README.md" "${DOC_DIR}/${PACKAGE_NAME}/README.md" + echo "Installed documentation to ${DOC_DIR}" + + # Install license. + ensure try_sudo mkdir -p -- "${LIC_DIR}/${PACKAGE_NAME}" + ensure try_sudo cp -- "${_filename_no_ext}/COPYRIGHT" "${LIC_DIR}/${PACKAGE_NAME}/COPYRIGHT" + ensure try_sudo cp -- "${_filename_no_ext}/LICENSE-APACHE" "${LIC_DIR}/${PACKAGE_NAME}/LICENSE-APACHE" + ensure try_sudo cp -- "${_filename_no_ext}/LICENSE-MIT" "${LIC_DIR}/${PACKAGE_NAME}/LICENSE-MIT" + echo "Installed license to ${LIC_DIR}" + + # Print success message and check $PATH. + echo "" + echo "${PACKAGE_NAME} is installed!" + if ! echo ":${PATH}:" | grep -Fq ":${BIN_DIR}:"; then + echo "Note: ${BIN_DIR} is not on your \$PATH. ${PACKAGE_NAME} will not work unless it is added to \$PATH." + fi +} + +# Parse the arguments passed and set variables accordingly. +parse_args() { + BIN_DIR_DEFAULT="${HOME}/.local/bin" + MAN_DIR_DEFAULT="${HOME}/.local/share/man" + DOC_DIR_DEFAULT="${HOME}/.local/share/doc" + LIC_DIR_DEFAULT="${HOME}/.local/share/licenses" + SUDO_DEFAULT="sudo" + + BIN_DIR="${BIN_DIR_DEFAULT}" + MAN_DIR="${MAN_DIR_DEFAULT}" + DOC_DIR="${DOC_DIR_DEFAULT}" + LIC_DIR="${LIC_DIR_DEFAULT}" + SUDO="${SUDO_DEFAULT}" + + while [ "$#" -gt 0 ]; do + case "$1" in + --arch) ARCH="$2" && shift 2 ;; + --arch=*) ARCH="${1#*=}" && shift 1 ;; + --bin-dir) BIN_DIR="$2" && shift 2 ;; + --bin-dir=*) BIN_DIR="${1#*=}" && shift 1 ;; + --man-dir) MAN_DIR="$2" && shift 2 ;; + --man-dir=*) MAN_DIR="${1#*=}" && shift 1 ;; + --sudo) SUDO="$2" && shift 2 ;; + --sudo=*) SUDO="${1#*=}" && shift 1 ;; + -h | --help) usage && exit 0 ;; + *) err "Unknown option: $1" ;; + esac + done +} + +usage() { + # heredocs are not defined in POSIX. + local _text_heading _text_reset + _text_heading="$(tput bold || true 2>/dev/null)$(tput smul || true 2>/dev/null)" + _text_reset="$(tput sgr0 || true 2>/dev/null)" + + local _arch + _arch="$(get_architecture || true)" + + cat <<EOF +${_text_heading}${PACKAGE_NAME} installer${_text_reset} +Edward Fitz Abucay <gh:ffimnsr> +https://github.com/ffimnsr/${PACKAGE_NAME}-rs + +Fetches and installs ${PACKAGE_NAME}. If ${PACKAGE_NAME} is already installed, it will be updated to the latest version. + +${_text_heading}Usage:${_text_reset} + install.sh [OPTIONS] + +${_text_heading}Options:${_text_reset} + --arch Override the architecture identified by the installer [current: ${_arch}] + --bin-dir Override the installation directory [default: ${BIN_DIR_DEFAULT}] + --man-dir Override the manpage installation directory [default: ${MAN_DIR_DEFAULT}] + --sudo Override the command used to elevate to root privileges [default: ${SUDO_DEFAULT}] + -h, --help Print help" +EOF +} + +download_pkg() { + local _arch="$1" + + if check_cmd curl; then + _dld=curl + elif check_cmd wget; then + _dld=wget + else + need_cmd 'curl or wget' + fi + need_cmd grep + + local _releases_url="https://api.github.com/repos/ffimnsr/${PACKAGE_NAME}-rs/releases/latest" + local _releases + case "${_dld}" in + curl) _releases="$(curl -sL "${_releases_url}")" || + err "curl: failed to download ${_releases_url}" ;; + wget) _releases="$(wget -qO- "${_releases_url}")" || + err "wget: failed to download ${_releases_url}" ;; + *) err "unsupported downloader: ${_dld}" ;; + esac + (echo "${_releases}" | grep -q 'API rate limit exceeded') && + err "you have exceeded GitHub's API rate limit. Please try again later, or use a different installation method: https://github.com/ffimnsr/${PACKAGE_NAME}-rs/#installation" + + local _package_url + _package_url="$(echo "${_releases}" | grep "browser_download_url" | cut -d '"' -f 4 | grep -- "${_arch}\(.tar.gz\|.zip\)$")" || + err "${PACKAGE_NAME} has not yet been packaged for your architecture (${_arch}), please file an issue: https://github.com/ffimnsr/${PACKAGE_NAME}-rs/issues" + + local _filename + _filename=$(basename "${_package_url}") + + # TODO: + # - Check if the package checksum is available and verify it. + + local _ext + case "${_package_url}" in + *.tar.gz) _ext="tar.gz" ;; + *.zip) _ext="zip" ;; + *) err "unsupported package format: ${_package_url}" ;; + esac + + local _package="${_filename}" || "${PACKAGE_NAME}.${_ext}" + case "${_dld}" in + curl) _releases="$(curl -sLo "${_package}" "${_package_url}")" || err "curl: failed to download ${_package_url}" ;; + wget) _releases="$(wget -qO "${_package}" "${_package_url}")" || err "wget: failed to download ${_package_url}" ;; + *) err "unsupported downloader: ${_dld}" ;; + esac + + echo "${_package}" +} + +try_sudo() { + if "$@" >/dev/null 2>&1; then + return 0 + fi + + need_sudo + "${SUDO}" "$@" +} + +need_sudo() { + if ! check_cmd "${SUDO}"; then + err "\ +could not find the command \`${SUDO}\` needed to get permissions for install. + +If you are on Windows, please run your shell as an administrator, then rerun this script. +Otherwise, please run this script as root, or install \`sudo\`." + fi + + if ! "${SUDO}" -v; then + err "sudo permissions not granted, aborting installation" + fi +} + +# The below functions have been extracted with minor modifications from the +# Rustup install script: +# https://github.com/rust-lang/rustup/blob/4c1289b2c3f3702783900934a38d7c5f912af787/rustup-init.sh +get_architecture() { + local _ostype _cputype _bitness _arch _clibtype + _ostype="$(uname -s)" + _cputype="$(uname -m)" + _clibtype="musl" + + if [ "${_ostype}" = Linux ]; then + if [ "$(uname -o || true)" = Android ]; then + _ostype=Android + fi + fi + + if [ "${_ostype}" = Darwin ] && [ "${_cputype}" = i386 ]; then + # Darwin `uname -m` lies + if sysctl hw.optional.x86_64 | grep -q ': 1'; then + _cputype=x86_64 + fi + fi + + if [ "${_ostype}" = SunOS ]; then + # Both Solaris and illumos presently announce as "SunOS" in "uname -s" + # so use "uname -o" to disambiguate. We use the full path to the + # system uname in case the user has coreutils uname first in PATH, + # which has historically sometimes printed the wrong value here. + if [ "$(/usr/bin/uname -o || true)" = illumos ]; then + _ostype=illumos + fi + + # illumos systems have multi-arch userlands, and "uname -m" reports the + # machine hardware name; e.g., "i86pc" on both 32- and 64-bit x86 + # systems. Check for the native (widest) instruction set on the + # running kernel: + if [ "${_cputype}" = i86pc ]; then + _cputype="$(isainfo -n)" + fi + fi + + case "${_ostype}" in + Android) + _ostype=linux-android + ;; + Linux) + check_proc + _ostype=unknown-linux-${_clibtype} + _bitness=$(get_bitness) + ;; + FreeBSD) + _ostype=unknown-freebsd + ;; + NetBSD) + _ostype=unknown-netbsd + ;; + DragonFly) + _ostype=unknown-dragonfly + ;; + Darwin) + _ostype=apple-darwin + ;; + illumos) + _ostype=unknown-illumos + ;; + MINGW* | MSYS* | CYGWIN* | Windows_NT) + _ostype=pc-windows-msvc + ;; + *) + err "unrecognized OS type: ${_ostype}" + ;; + esac + + case "${_cputype}" in + i386 | i486 | i686 | i786 | x86) + _cputype=i686 + ;; + xscale | arm) + _cputype=arm + if [ "${_ostype}" = "linux-android" ]; then + _ostype=linux-androideabi + fi + ;; + armv6l) + _cputype=arm + if [ "${_ostype}" = "linux-android" ]; then + _ostype=linux-androideabi + else + _ostype="${_ostype}eabihf" + fi + ;; + armv7l | armv8l) + _cputype=armv7 + if [ "${_ostype}" = "linux-android" ]; then + _ostype=linux-androideabi + else + _ostype="${_ostype}eabihf" + fi + ;; + aarch64 | arm64) + _cputype=aarch64 + ;; + x86_64 | x86-64 | x64 | amd64) + _cputype=x86_64 + ;; + mips) + _cputype=$(get_endianness mips '' el) + ;; + mips64) + if [ "${_bitness}" -eq 64 ]; then + # only n64 ABI is supported for now + _ostype="${_ostype}abi64" + _cputype=$(get_endianness mips64 '' el) + fi + ;; + ppc) + _cputype=powerpc + ;; + ppc64) + _cputype=powerpc64 + ;; + ppc64le) + _cputype=powerpc64le + ;; + s390x) + _cputype=s390x + ;; + riscv64) + _cputype=riscv64gc + ;; + *) + err "unknown CPU type: ${_cputype}" + ;; + esac + + # Detect 64-bit linux with 32-bit userland + if [ "${_ostype}" = unknown-linux-musl ] && [ "${_bitness}" -eq 32 ]; then + case ${_cputype} in + x86_64) + # 32-bit executable for amd64 = x32 + if is_host_amd64_elf; then { + err "x32 userland is unsupported" + }; else + _cputype=i686 + fi + ;; + mips64) + _cputype=$(get_endianness mips '' el) + ;; + powerpc64) + _cputype=powerpc + ;; + aarch64) + _cputype=armv7 + if [ "${_ostype}" = "linux-android" ]; then + _ostype=linux-androideabi + else + _ostype="${_ostype}eabihf" + fi + ;; + riscv64gc) + err "riscv64 with 32-bit userland unsupported" + ;; + *) ;; + esac + fi + + # Detect armv7 but without the CPU features Rust needs in that build, + # and fall back to arm. + # See https://github.com/rust-lang/rustup.rs/issues/587. + if [ "${_ostype}" = "unknown-linux-musleabihf" ] && [ "${_cputype}" = armv7 ]; then + if ensure grep '^Features' /proc/cpuinfo | grep -q -v neon; then + # At least one processor does not have NEON. + _cputype=arm + fi + fi + + _arch="${_cputype}-${_ostype}" + echo "${_arch}" +} + +get_bitness() { + need_cmd head + # Architecture detection without dependencies beyond coreutils. + # ELF files start out "\x7fELF", and the following byte is + # 0x01 for 32-bit and + # 0x02 for 64-bit. + # The printf builtin on some shells like dash only supports octal + # escape sequences, so we use those. + local _current_exe_head + _current_exe_head=$(head -c 5 /proc/self/exe) + if [ "${_current_exe_head}" = "$(printf '\177ELF\001')" ]; then + echo 32 + elif [ "${_current_exe_head}" = "$(printf '\177ELF\002')" ]; then + echo 64 + else + err "unknown platform bitness" + fi +} + +get_endianness() { + local cputype="$1" + local suffix_eb="$2" + local suffix_el="$3" + + # detect endianness without od/hexdump, like get_bitness() does. + need_cmd head + need_cmd tail + + local _current_exe_endianness + _current_exe_endianness="$(head -c 6 /proc/self/exe | tail -c 1)" + if [ "${_current_exe_endianness}" = "$(printf '\001')" ]; then + echo "${cputype}${suffix_el}" + elif [ "${_current_exe_endianness}" = "$(printf '\002')" ]; then + echo "${cputype}${suffix_eb}" + else + err "unknown platform endianness" + fi +} + +is_host_amd64_elf() { + need_cmd head + need_cmd tail + # ELF e_machine detection without dependencies beyond coreutils. + # Two-byte field at offset 0x12 indicates the CPU, + # but we're interested in it being 0x3E to indicate amd64, or not that. + local _current_exe_machine + _current_exe_machine=$(head -c 19 /proc/self/exe | tail -c 1) + [ "${_current_exe_machine}" = "$(printf '\076')" ] +} + +check_proc() { + # Check for /proc by looking for the /proc/self/exe link. + # This is only run on Linux. + if ! test -L /proc/self/exe; then + err "unable to find /proc/self/exe. Is /proc mounted? Installation cannot proceed without /proc." + fi +} + +need_cmd() { + if ! check_cmd "$1"; then + err "need '$1' (command not found)" + fi +} + +check_cmd() { + command -v -- "$1" >/dev/null 2>&1 +} + +# Run a command that should never fail. If the command fails execution +# will immediately terminate with an error showing the failing +# command. +ensure() { + if ! "$@"; then + err "command failed: $*"; + fi +} + +assert_nz() { + if [ -z "$1" ]; then + err "found empty string: $2"; + fi +} + +err() { + echo "Error: $1" >&2 + exit 1 +} + +# This is put in braces to ensure that the script does not run until it is +# downloaded completely. +{ + main "$@" || exit 1 +} diff --git a/sample_migrations_mysql/.gitkeep b/sample_migrations_mysql/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sample_migrations/0000000000000_initial.sql b/sample_migrations_mysql/0000000000000_initial.sql similarity index 58% rename from sample_migrations/0000000000000_initial.sql rename to sample_migrations_mysql/0000000000000_initial.sql index 6dfcdb7..2ea0b2b 100644 --- a/sample_migrations/0000000000000_initial.sql +++ b/sample_migrations_mysql/0000000000000_initial.sql @@ -1,6 +1,6 @@ -- # Put the your SQL below migration seperator. -- !UP --- CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY); +CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY); -- !DOWN -- DROP TABLE users; diff --git a/sample_migrations_sqlite/.gitkeep b/sample_migrations_sqlite/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sample_migrations_sqlite/0000000000000_initial.sql b/sample_migrations_sqlite/0000000000000_initial.sql new file mode 100644 index 0000000..2ea0b2b --- /dev/null +++ b/sample_migrations_sqlite/0000000000000_initial.sql @@ -0,0 +1,6 @@ +-- # Put the your SQL below migration seperator. +-- !UP +CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY); + +-- !DOWN +-- DROP TABLE users; diff --git a/src/commander.rs b/src/commander.rs index d32293a..4d1417d 100644 --- a/src/commander.rs +++ b/src/commander.rs @@ -65,6 +65,14 @@ fn ensure_migration_state_dir_exists() -> AnyhowResult<()> { Ok(()) } +fn progress_style() -> AnyhowResult<ProgressStyle> { + let style = ProgressStyle::default_bar() + .template("{spinner:.green} [{prefix:.bold.dim}] {wide_msg:.cyan/blue} ")? + .tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⦿"); + + Ok(style) +} + impl<T: SequelDriver + 'static + ?Sized> Migrator<T> { pub fn new(executor: Box<T>, migrations: MigrationFiles) -> Self { Self { executor, migrations } @@ -156,10 +164,7 @@ impl<T: SequelDriver + 'static + ?Sized> Migrator<T> { let pb = ProgressBar::new(filtered.len() as u64); let tick_interval = Duration::from_millis(80); - pb.set_style( - ProgressStyle::with_template("{spinner:.green} [{prefix:.bold.dim}] {wide_msg:.cyan/blue} ")? - .tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⦿"), - ); + pb.set_style(progress_style()?); pb.enable_steady_tick(tick_interval); let mut rng = rand::thread_rng(); for it in &filtered { @@ -201,10 +206,7 @@ impl<T: SequelDriver + 'static + ?Sized> Migrator<T> { let pb = ProgressBar::new(completed_migrations.len() as u64); let tick_interval = Duration::from_millis(80); - pb.set_style( - ProgressStyle::with_template("{spinner:.green} [{prefix:.bold.dim}] {wide_msg:.cyan/blue} ")? - .tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⦿"), - ); + pb.set_style(progress_style()?); pb.enable_steady_tick(tick_interval); let mut rng = rand::thread_rng(); for it in completed_migrations.iter().rev() { @@ -253,10 +255,7 @@ impl<T: SequelDriver + 'static + ?Sized> Migrator<T> { let pb = ProgressBar::new(1u64); let tick_interval = Duration::from_millis(80); - pb.set_style( - ProgressStyle::with_template("{spinner:.green} [{prefix:.bold.dim}] {wide_msg:.cyan/blue} ")? - .tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⦿"), - ); + pb.set_style(progress_style()?); pb.enable_steady_tick(tick_interval); pb.set_prefix(format!("{current:013}")); pb.tick(); @@ -311,10 +310,7 @@ impl<T: SequelDriver + 'static + ?Sized> Migrator<T> { let pb = ProgressBar::new(1u64); let tick_interval = Duration::from_millis(80); - pb.set_style( - ProgressStyle::with_template("{spinner:.green} [{prefix:.bold.dim}] {wide_msg:.cyan/blue} ")? - .tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⦿"), - ); + pb.set_style(progress_style()?); pb.enable_steady_tick(tick_interval); pb.set_prefix(format!("{current:013}")); pb.tick(); @@ -344,13 +340,15 @@ impl<T: SequelDriver + 'static + ?Sized> Migrator<T> { let mut f = File::create(filepath)?; let contents = formatdoc! {" DATABASE_URL={} - MIGRATIONS_ROOT={} + MIGRATIONS_DIR={} ", db_url, source}; f.write_all(contents.as_bytes())?; f.sync_all()?; log::trace!("Creating new migrations directory: {:?}", source_path); - fs::create_dir_all(source_path)?; + if !source_path.exists() { + fs::create_dir_all(source_path)?; + } Ok(()) } diff --git a/src/lookup.rs b/src/lookup.rs index c72ee5f..89b4539 100644 --- a/src/lookup.rs +++ b/src/lookup.rs @@ -6,12 +6,13 @@ use indoc::indoc; use regex::Regex; use std::collections::BTreeMap; use std::fs::{ - read_dir, + self, File, }; use std::io::prelude::*; use std::io::BufReader; use std::path::Path; +use std::string::ToString; use std::time::{ SystemTime, UNIX_EPOCH, @@ -59,9 +60,9 @@ fn parse_file(filename: &str) -> AnyhowResult<MigrationFile> { pub fn build_migration_list(path: &Path) -> AnyhowResult<MigrationFiles> { let mut files: MigrationFiles = BTreeMap::new(); + let entries = fs::read_dir(path)?.filter_map(Result::ok).collect::<Vec<_>>(); - for entry in read_dir(path)? { - let entry = entry?; + for entry in entries { let filename = entry.file_name(); let Ok(info) = parse_file(filename.to_str().context("Filename is not valid")?) else { continue; @@ -72,10 +73,7 @@ pub fn build_migration_list(path: &Path) -> AnyhowResult<MigrationFiles> { let mut content = String::new(); buf_reader.read_to_string(&mut content)?; - let split_vec: Vec<String> = content - .split('\n') - .map(std::string::ToString::to_string) - .collect(); + let split_vec: Vec<String> = content.split('\n').map(ToString::to_string).collect(); let pos_up = split_vec .iter() @@ -109,6 +107,7 @@ fn timestamp() -> String { since_the_epoch.as_millis().to_string() } +// Create a new migration file pub fn create_migration_file(path: &Path, slug: &str) -> AnyhowResult<()> { let filename = timestamp() + "_" + slug + ".sql"; let filepath = path.join(filename); @@ -116,7 +115,7 @@ pub fn create_migration_file(path: &Path, slug: &str) -> AnyhowResult<()> { log::trace!("Creating new migration file: {:?}", filepath); let mut f = File::create(filepath)?; let contents = indoc! {"\ - -- # Put the your SQL below migration seperator. + -- # Put your SQL below migration seperator. -- !UP -- !DOWN diff --git a/src/midas/bin/cli.rs b/src/midas/bin/cli.rs index 1f0ae5a..5a411a6 100644 --- a/src/midas/bin/cli.rs +++ b/src/midas/bin/cli.rs @@ -19,6 +19,7 @@ use midas_core::sequel::mysql::Mysql; use midas_core::sequel::postgres::Postgres; use midas_core::sequel::sqlite::Sqlite; use midas_core::sequel::Driver as SequelDriver; +use tracing_subscriber::EnvFilter; pub(crate) fn midas_entry(command_name: &str, sub_command: bool) -> AnyhowResult<()> { dotenv::dotenv() @@ -30,12 +31,12 @@ pub(crate) fn midas_entry(command_name: &str, sub_command: bool) -> AnyhowResult } tracing_subscriber::fmt() - .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .with_env_filter(EnvFilter::from_default_env()) .init(); let cname = command_name.to_owned(); let mut cli_app = if sub_command { - Command::new(cname.clone()) + Command::new(cname) } else { Command::new(cname.clone()).bin_name(cname) }; @@ -50,6 +51,10 @@ pub(crate) fn midas_entry(command_name: &str, sub_command: bool) -> AnyhowResult Arg::new("database") .short('d') .long("database") + .env("DATABASE_URL") + .env("DATABASE_URI") + .env("DB_URL") + .env("DSN") .value_name("URL") .help("Sets the database connection url") .num_args(1), @@ -58,6 +63,9 @@ pub(crate) fn midas_entry(command_name: &str, sub_command: bool) -> AnyhowResult Arg::new("source") .short('s') .long("source") + .env("MIGRATIONS_ROOT") + .env("MIGRATIONS_PATH") + .env("MIGRATIONS_DIR") .value_name("DIR") .help("Sets the migration store directory") .num_args(1), @@ -68,7 +76,19 @@ pub(crate) fn midas_entry(command_name: &str, sub_command: bool) -> AnyhowResult .arg(Arg::new("name").help("The migration action name").required(true)), ) .subcommand(Command::new("status").about("Checks the status of the migration")) - .subcommand(Command::new("up").about("Apply all non-applied migrations")) + .subcommand(Command::new("up").about("Apply all pending migrations")) + .subcommand( + Command::new("upto") + .about("Apply all migrations up to the given migration number") + .arg( + Arg::new("migration_number") + .value_name("N") + .help("The migration number to apply up to") + .num_args(1) + .value_parser(clap::value_parser!(usize)) + .required(true), + ), + ) .subcommand(Command::new("down").about("Remove all applied migrations")) .subcommand(Command::new("redo").about("Redo the last migration")) .subcommand( @@ -83,11 +103,12 @@ pub(crate) fn midas_entry(command_name: &str, sub_command: bool) -> AnyhowResult .default_value("1"), ), ) - .subcommand(Command::new("init").about("Setups and creates initial file directory and env")) + .subcommand(Command::new("init").about("Setup and creates initial migration directory and a dotenv file")) .subcommand( Command::new("drop") .about("Drops everything inside the database (NOTE: must have create/drop privilege)"), - ); + ) + .subcommand(Command::new("completion").about("Generates shell completion scripts")); let matches = if sub_command { let internal_matches = Command::new("cargo") @@ -103,29 +124,14 @@ pub(crate) fn midas_entry(command_name: &str, sub_command: bool) -> AnyhowResult cli_app.get_matches() }; - // Read the database connection url from the environment variables - // From the following possible sources: - // 1. DATABASE_URL - // 2. DB_URL - // 3. DSN - let env_db_url_1 = env::var("DATABASE_URL").ok(); - let env_db_url_2 = env::var("DB_URL").ok(); - let env_db_url_3 = env::var("DSN").ok(); let db_url = matches .get_one::<String>("database") - .or(env_db_url_1.as_ref()) - .or(env_db_url_2.as_ref()) - .or(env_db_url_3.as_ref()) .context("No database connection url was provided")?; log::trace!("Using DSN: {}", db_url); let default_source_path = Some("migrations".to_string()); - let env_source_path_1 = env::var("MIGRATIONS_ROOT").ok(); - let env_source_path_2 = env::var("MIGRATIONS_DIR").ok(); let source = matches .get_one::<String>("source") - .or(env_source_path_1.as_ref()) - .or(env_source_path_2.as_ref()) .or(default_source_path.as_ref()) .context("No migration source path was provided")?; @@ -149,6 +155,15 @@ pub(crate) fn midas_entry(command_name: &str, sub_command: bool) -> AnyhowResult }, Some("status") => migrator.status()?, Some("up") => migrator.up()?, + Some("upto") => { + let _value = matches + .subcommand_matches("upto") + .context("No subcommand migration number was detected")? + .get_one::<usize>("migration_number") + .context("Migration number was invalid")?; + + unimplemented!(); + }, Some("down") => migrator.down()?, Some("redo") => migrator.redo()?, Some("revert") => { diff --git a/src/midas/bin/main.rs b/src/midas/bin/main.rs index 9b26892..61ef1f0 100644 --- a/src/midas/bin/main.rs +++ b/src/midas/bin/main.rs @@ -2,8 +2,10 @@ mod cli; use anyhow::Result as AnyhowResult; +/// The package name const PKG_NAME: &str = env!("CARGO_PKG_NAME"); +/// The main entry point for the migration command fn main() -> AnyhowResult<()> { cli::midas_entry(PKG_NAME, false)?; Ok(()) diff --git a/src/midas/bin/migrate_main.rs b/src/midas/bin/migrate_main.rs index 60e4c2c..fd220ad 100644 --- a/src/midas/bin/migrate_main.rs +++ b/src/midas/bin/migrate_main.rs @@ -2,6 +2,7 @@ mod cli; use anyhow::Result as AnyhowResult; +/// The main entry point for the migration command fn main() -> AnyhowResult<()> { cli::midas_entry("migrate", true)?; Ok(())