From 19c42f61388e34ff286fe6c5968846528f7d4491 Mon Sep 17 00:00:00 2001 From: TymanWasTaken Date: Sat, 1 Jul 2023 13:10:32 -0400 Subject: [PATCH] Migrate to sqlite+sea_orm --- Cargo.lock | 1252 ++++++++++++++++- Cargo.toml | 5 +- crates/asp/src/keys/mod.rs | 21 + src/commands/keys/export.rs | 22 +- src/commands/keys/generate.rs | 64 +- src/commands/keys/list.rs | 40 +- src/commands/mod.rs | 3 +- src/db.rs | 128 -- src/entities/keys.rs | 18 + src/entities/mod.rs | 5 + src/entities/prelude.rs | 3 + src/main.rs | 49 +- .../m_20230701_000001_create_keys_table.rs | 48 + src/migrations/mod.rs | 11 + 14 files changed, 1423 insertions(+), 246 deletions(-) delete mode 100644 src/db.rs create mode 100644 src/entities/keys.rs create mode 100644 src/entities/mod.rs create mode 100644 src/entities/prelude.rs create mode 100644 src/migrations/m_20230701_000001_create_keys_table.rs create mode 100644 src/migrations/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 091ce16..e02d9c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,49 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" + +[[package]] +name = "addr2line" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "1.0.2" @@ -17,6 +54,33 @@ dependencies = [ "memchr", ] +[[package]] +name = "aliasable" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" + +[[package]] +name = "allocator-api2" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56fc6cf8dc8c4158eed8649f9b8b0ea1518eb62b544fe9490d66fa0b349eafe9" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" version = "0.3.2" @@ -129,12 +193,57 @@ dependencies = [ "app_dirs2", "argon2", "asp", - "clap", + "async-trait", + "clap 4.3.9", "data-encoding", "dialoguer", "indoc", - "redb", + "sea-orm", + "sea-orm-migration", "thiserror", + "tokio", +] + +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.22", +] + +[[package]] +name = "async-trait" +version = "0.1.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.22", +] + +[[package]] +name = "atoi" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" +dependencies = [ + "num-traits", ] [[package]] @@ -143,6 +252,34 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bae" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b8de67cc41132507eeece2584804efcb15f85ba516e34c944b7667f480397a" +dependencies = [ + "heck 0.3.3", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "base64" version = "0.21.2" @@ -155,12 +292,35 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bigdecimal" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "blake2" version = "0.10.6" @@ -179,12 +339,85 @@ dependencies = [ "generic-array", ] +[[package]] +name = "borsh" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +dependencies = [ + "borsh-derive", + "hashbrown 0.12.3", +] + +[[package]] +name = "borsh-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +dependencies = [ + "borsh-derive-internal", + "borsh-schema-derive-internal", + "proc-macro-crate", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "bumpalo" version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +[[package]] +name = "bytecheck" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + [[package]] name = "bytes" version = "1.4.0" @@ -209,6 +442,33 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "winapi", +] + +[[package]] +name = "clap" +version = "3.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +dependencies = [ + "bitflags", + "clap_derive 3.2.25", + "clap_lex 0.2.4", + "indexmap 1.9.3", + "once_cell", + "textwrap", +] + [[package]] name = "clap" version = "4.3.9" @@ -216,7 +476,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bba77a07e4489fb41bd90e8d4201c3eb246b3c2c9ea2ba0bddd6c1d1df87db7d" dependencies = [ "clap_builder", - "clap_derive", + "clap_derive 4.3.2", "once_cell", ] @@ -229,20 +489,42 @@ dependencies = [ "anstream", "anstyle", "bitflags", - "clap_lex", + "clap_lex 0.5.0", "strsim", ] +[[package]] +name = "clap_derive" +version = "3.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" +dependencies = [ + "heck 0.4.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "clap_derive" version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", - "syn", + "syn 2.0.22", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", ] [[package]] @@ -314,6 +596,25 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -353,6 +654,18 @@ dependencies = [ "subtle", ] +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + [[package]] name = "email_address" version = "0.2.4" @@ -404,6 +717,12 @@ dependencies = [ "libc", ] +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + [[package]] name = "fastrand" version = "1.9.0" @@ -423,6 +742,18 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "flume" +version = "0.10.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +dependencies = [ + "futures-core", + "futures-sink", + "pin-project", + "spin", +] + [[package]] name = "fnv" version = "1.0.7" @@ -453,6 +784,26 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.28" @@ -460,6 +811,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -468,6 +820,34 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +[[package]] +name = "futures-executor" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + [[package]] name = "futures-sink" version = "0.3.28" @@ -486,10 +866,15 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -513,6 +898,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" + [[package]] name = "h2" version = "0.3.20" @@ -537,18 +928,46 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.6", +] [[package]] name = "hashbrown" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +dependencies = [ + "ahash 0.8.3", + "allocator-api2", +] + +[[package]] +name = "hashlink" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "312f66718a2d7789ffef4f4b7b213138ed9f1eb3aa1d0d82fc99f88fb3ffd26f" +dependencies = [ + "hashbrown 0.14.0", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] [[package]] name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] [[package]] name = "hermit-abi" @@ -565,6 +984,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "hex_color" version = "2.0.0" @@ -656,6 +1081,29 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "iana-time-zone" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "idna" version = "0.4.0" @@ -730,6 +1178,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.6" @@ -797,18 +1254,48 @@ version = "0.2.146" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" +[[package]] +name = "libsqlite3-sys" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "lock_api" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + [[package]] name = "memchr" version = "2.5.0" @@ -821,6 +1308,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -865,6 +1358,46 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.15.0" @@ -875,6 +1408,15 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.18.0" @@ -904,7 +1446,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.22", ] [[package]] @@ -925,6 +1467,60 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_str_bytes" +version = "6.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" + +[[package]] +name = "ouroboros" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1358bd1558bd2a083fed428ffeda486fbfb323e698cdda7794259d592ca72db" +dependencies = [ + "aliasable", + "ouroboros_macro", +] + +[[package]] +name = "ouroboros_macro" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f7d21ccd03305a674437ee1248f3ab5d4b1db095cf1caf49f1713ddf61956b7" +dependencies = [ + "Inflector", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", +] + [[package]] name = "password-hash" version = "0.5.0" @@ -936,12 +1532,38 @@ dependencies = [ "subtle", ] +[[package]] +name = "paste" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" + [[package]] name = "percent-encoding" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +[[package]] +name = "pin-project" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.22", +] + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -966,6 +1588,39 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.63" @@ -976,13 +1631,23 @@ dependencies = [ ] [[package]] -name = "pyo3-build-config" -version = "0.19.0" +name = "ptr_meta" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713eccf888fb05f1a96eb78c0dbc51907fee42b3377272dc902eb38985f418d5" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" dependencies = [ - "once_cell", - "target-lexicon", + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -994,6 +1659,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.5" @@ -1025,13 +1696,12 @@ dependencies = [ ] [[package]] -name = "redb" -version = "1.0.3" +name = "redox_syscall" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f41f3c1c8851dafca590c6ccfaa254a694a8e002a754352e68fac81371988838" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "libc", - "pyo3-build-config", + "bitflags", ] [[package]] @@ -1051,15 +1721,39 @@ checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.7.2", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +[[package]] +name = "rend" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" +dependencies = [ + "bytecheck", +] + [[package]] name = "reqwest" version = "0.11.18" @@ -1097,6 +1791,58 @@ dependencies = [ "winreg", ] +[[package]] +name = "rkyv" +version = "0.7.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" +dependencies = [ + "bitvec", + "bytecheck", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rust_decimal" +version = "1.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0446843641c69436765a35a5a77088e28c2e6a12da93e84aa3ab1cd4aa5a042" +dependencies = [ + "arrayvec", + "borsh", + "bytecheck", + "byteorder", + "bytes", + "num-traits", + "rand", + "rkyv", + "serde", + "serde_json", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + [[package]] name = "rustix" version = "0.37.20" @@ -1111,6 +1857,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustversion" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" + [[package]] name = "ryu" version = "1.0.13" @@ -1135,6 +1887,181 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sea-orm" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fade86e8d41fd1a4721f84cb834f4ca2783f973cc30e6212b7fafc134f169214" +dependencies = [ + "async-stream", + "async-trait", + "bigdecimal", + "chrono", + "futures", + "log", + "ouroboros", + "rust_decimal", + "sea-orm-macros", + "sea-query", + "sea-query-binder", + "sea-strum", + "serde", + "serde_json", + "sqlx", + "thiserror", + "time", + "tracing", + "url", + "uuid", +] + +[[package]] +name = "sea-orm-cli" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbf34a2caf70c2e3be9bb1e674e9540f6dfd7c8f40f6f05daf3b9740e476005" +dependencies = [ + "chrono", + "clap 3.2.25", + "dotenvy", + "regex", + "sea-schema", + "tracing", + "tracing-subscriber", + "url", +] + +[[package]] +name = "sea-orm-macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28936f26d62234ff0be16f80115dbdeb3237fe9c25cf18fbcd1e3b3592360f20" +dependencies = [ + "bae", + "heck 0.3.3", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "sea-orm-migration" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "278d3adfd0832b6ffc17d3cfbc574d3695a5c1b38814e0bc8ac238d33f3d87cf" +dependencies = [ + "async-trait", + "clap 3.2.25", + "dotenvy", + "futures", + "sea-orm", + "sea-orm-cli", + "sea-schema", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "sea-query" +version = "0.28.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbab99b8cd878ab7786157b7eb8df96333a6807cc6e45e8888c85b51534b401a" +dependencies = [ + "bigdecimal", + "chrono", + "rust_decimal", + "sea-query-derive", + "serde_json", + "time", + "uuid", +] + +[[package]] +name = "sea-query-binder" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cea85029985b40dfbf18318d85fe985c04db7c1b4e5e8e0a0a0cdff5f1e30f9" +dependencies = [ + "bigdecimal", + "chrono", + "rust_decimal", + "sea-query", + "serde_json", + "sqlx", + "time", + "uuid", +] + +[[package]] +name = "sea-query-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63f62030c60f3a691f5fe251713b4e220b306e50a71e1d6f9cce1f24bb781978" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 1.0.109", + "thiserror", +] + +[[package]] +name = "sea-schema" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeb2940bb5a10bc6cd05b450ce6cd3993e27fddd7eface2becb97fc5af3a040e" +dependencies = [ + "futures", + "sea-query", + "sea-schema-derive", +] + +[[package]] +name = "sea-schema-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56821b7076f5096b8f726e2791ad255a99c82498e08ec477a65a96c461ff1927" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "sea-strum" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391d06a6007842cfe79ac6f7f53911b76dfd69fc9a6769f1cf6569d12ce20e1b" +dependencies = [ + "sea-strum_macros", +] + +[[package]] +name = "sea-strum_macros" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69b4397b825df6ccf1e98bcdabef3bbcfc47ff5853983467850eeab878384f21" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + [[package]] name = "security-framework" version = "2.9.1" @@ -1185,7 +2112,7 @@ checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.22", ] [[package]] @@ -1223,12 +2150,27 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + [[package]] name = "shell-words" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + [[package]] name = "slab" version = "0.4.8" @@ -1238,6 +2180,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + [[package]] name = "socket2" version = "0.4.9" @@ -1248,6 +2196,126 @@ dependencies = [ "winapi", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "sqlformat" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c12bc9199d1db8234678b7051747c07f517cdcf019262d1847b94ec8b1aee3e" +dependencies = [ + "itertools", + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8de3b03a925878ed54a954f621e64bf55a3c1bd29652d0d1a17830405350188" +dependencies = [ + "sqlx-core", + "sqlx-macros", +] + +[[package]] +name = "sqlx-core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" +dependencies = [ + "ahash 0.7.6", + "atoi", + "bigdecimal", + "bitflags", + "byteorder", + "bytes", + "chrono", + "crossbeam-queue", + "dotenvy", + "either", + "event-listener", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "hashlink", + "hex", + "indexmap 1.9.3", + "itoa", + "libc", + "libsqlite3-sys", + "log", + "memchr", + "num-bigint", + "once_cell", + "paste", + "percent-encoding", + "rust_decimal", + "serde", + "serde_json", + "smallvec", + "sqlformat", + "sqlx-rt", + "stringprep", + "thiserror", + "time", + "tokio-stream", + "url", + "uuid", +] + +[[package]] +name = "sqlx-macros" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9966e64ae989e7e575b19d7265cb79d7fc3cbbdf179835cb0d716f294c2049c9" +dependencies = [ + "dotenvy", + "either", + "heck 0.4.1", + "once_cell", + "proc-macro2", + "quote", + "serde_json", + "sqlx-core", + "sqlx-rt", + "syn 1.0.109", + "url", +] + +[[package]] +name = "sqlx-rt" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "804d3f245f894e61b1e6263c84b23ca675d96753b5abfd5cc8597d86806e8024" +dependencies = [ + "native-tls", + "once_cell", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "stringprep" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "strsim" version = "0.10.0" @@ -1260,6 +2328,17 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.22" @@ -1272,10 +2351,10 @@ dependencies = [ ] [[package]] -name = "target-lexicon" -version = "0.12.8" +name = "tap" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" @@ -1286,11 +2365,17 @@ dependencies = [ "autocfg", "cfg-if", "fastrand", - "redox_syscall", + "redox_syscall 0.3.5", "rustix", "windows-sys 0.48.0", ] +[[package]] +name = "textwrap" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" + [[package]] name = "thiserror" version = "1.0.40" @@ -1308,7 +2393,17 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.22", +] + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", ] [[package]] @@ -1317,8 +2412,10 @@ version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" dependencies = [ + "itoa", "serde", "time-core", + "time-macros", ] [[package]] @@ -1327,6 +2424,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +[[package]] +name = "time-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +dependencies = [ + "time-core", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -1344,11 +2450,12 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.2" +version = "1.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" +checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" dependencies = [ "autocfg", + "backtrace", "bytes", "libc", "mio", @@ -1367,7 +2474,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.22", ] [[package]] @@ -1380,6 +2487,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.8" @@ -1394,6 +2512,15 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -1407,10 +2534,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", + "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.22", +] + [[package]] name = "tracing-core" version = "0.1.31" @@ -1420,6 +2560,21 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tracing-subscriber" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +dependencies = [ + "matchers", + "once_cell", + "regex", + "sharded-slab", + "thread_local", + "tracing", + "tracing-core", +] + [[package]] name = "try-lock" version = "0.2.4" @@ -1453,12 +2608,24 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + [[package]] name = "unicode-width" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + [[package]] name = "url" version = "2.4.0" @@ -1477,6 +2644,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" +dependencies = [ + "serde", +] + [[package]] name = "vcpkg" version = "0.2.15" @@ -1535,7 +2711,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.22", "wasm-bindgen-shared", ] @@ -1569,7 +2745,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.22", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1621,6 +2797,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.0", +] + [[package]] name = "windows-sys" version = "0.42.0" @@ -1777,6 +2962,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "xdg" version = "2.5.0" diff --git a/Cargo.toml b/Cargo.toml index 865c72d..30f61a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,10 @@ thiserror = "1.0.40" asp = { path = "crates/asp" } indoc = "2.0.1" anstyle = "1.0.1" -redb = "1.0.3" dialoguer = { version = "0.10.4", features = ["password"] } argon2 = { version = "0.5.0", features = ["std"] } data-encoding = "2.4.0" +sea-orm = { version = "0.11.3", features = ["sqlx-sqlite", "runtime-tokio-native-tls"] } +tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] } +sea-orm-migration = "0.11.3" +async-trait = "0.1.68" diff --git a/crates/asp/src/keys/mod.rs b/crates/asp/src/keys/mod.rs index 5013d60..cf4d130 100644 --- a/crates/asp/src/keys/mod.rs +++ b/crates/asp/src/keys/mod.rs @@ -1,3 +1,4 @@ +use anyhow::bail; use josekit::{ jwk::{ alg::{ec::EcCurve, ed::EdCurve}, @@ -19,6 +20,26 @@ pub enum AspKeyType { ES256, } +impl Into for AspKeyType { + fn into(self) -> i32 { + match self { + Self::Ed25519 => 0, + Self::ES256 => 1, + } + } +} + +impl TryFrom for AspKeyType { + type Error = anyhow::Error; + fn try_from(value: i32) -> Result { + match value { + 0 => Ok(Self::Ed25519), + 1 => Ok(Self::ES256), + _ => bail!("Invalid index for AspKeyType"), + } + } +} + /// A struct representing a key that can be used to create profiles or ASPE requests #[derive(Debug)] pub struct AspKey { diff --git a/src/commands/keys/export.rs b/src/commands/keys/export.rs index 5e200e7..17fe650 100644 --- a/src/commands/keys/export.rs +++ b/src/commands/keys/export.rs @@ -4,9 +4,9 @@ use asp::keys::AspKey; use clap::{Parser, ValueEnum}; use data_encoding::BASE64_NOPAD; use dialoguer::{theme::ColorfulTheme, Password}; -use redb::ReadableTable; +use sea_orm::EntityTrait; -use crate::{commands::AspmSubcommand, db::KEYS_TABLE}; +use crate::{commands::AspmSubcommand, entities::keys}; #[derive(ValueEnum, Debug, Clone)] pub enum KeyExportFormat { @@ -29,20 +29,16 @@ pub struct KeysExportCommand { fingerprint: String, } +#[async_trait::async_trait] impl AspmSubcommand for KeysExportCommand { - fn execute(&self, state: crate::AspmState) -> Result<(), anyhow::Error> { - let txn = state - .db - .begin_read() - .context("Unable to start db read transaction")?; - let table = txn.open_table(KEYS_TABLE)?; - let entry = table - .get(&*self.fingerprint) + async fn execute(&self, state: crate::AspmState) -> Result<(), anyhow::Error> { + // Fetch key from db + let entry = keys::Entity::find_by_id(&self.fingerprint) + .one(&state.db) + .await .context("Unable to fetch key from database")?; if let Some(entry) = entry { - let value = entry.value(); - let key_password = std::env::var("KEY_PASSWORD").or_else(|_| { Password::with_theme(&ColorfulTheme::default()) .with_prompt("Please enter a password to decrypt the key with") @@ -61,7 +57,7 @@ impl AspmSubcommand for KeysExportCommand { let aes_key = hash.hash.context("Unable to derive encryption key")?; let aes_key = &aes_key.as_bytes()[0..32]; - if let Ok(decrypted) = AspKey::from_encrypted(aes_key, &value.key) { + if let Ok(decrypted) = AspKey::from_encrypted(aes_key, &entry.encrypted) { let export = match self.format { KeyExportFormat::Encrypted => decrypted .export_encrypted(aes_key) diff --git a/src/commands/keys/generate.rs b/src/commands/keys/generate.rs index 16d8852..ca6887f 100644 --- a/src/commands/keys/generate.rs +++ b/src/commands/keys/generate.rs @@ -1,15 +1,13 @@ -use anyhow::{anyhow, Context}; +use anyhow::{anyhow, bail, Context}; use argon2::{password_hash::SaltString, Argon2, PasswordHasher}; use asp::keys::{AspKey, AspKeyType}; use clap::{Parser, ValueEnum}; use data_encoding::BASE64_NOPAD; use dialoguer::{theme::ColorfulTheme, Input, Password}; use indoc::printdoc; +use sea_orm::{ActiveValue, EntityTrait}; -use crate::{ - commands::AspmSubcommand, - db::{KeysTableValue, KEYS_TABLE}, -}; +use crate::{commands::AspmSubcommand, entities::keys}; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)] pub enum KeyGenerationType { @@ -25,19 +23,23 @@ pub struct KeysGenerateCommand { /// It doesn't really matter that much which one is used, as they both work fine, but Ed25519 is used as a safe default. #[clap(value_enum, default_value_t = KeyGenerationType::Ed25519, long_about, ignore_case = true)] key_type: KeyGenerationType, + /// Tha alias of the key to generate. This can be anything, and it can also be omitted to prompt interactively. This has no purpose other than providing a way to nicely name keys, rather than having to remember a fingerprint. + #[arg(short = 'n', long)] + key_alias: Option, } +#[async_trait::async_trait] impl AspmSubcommand for KeysGenerateCommand { - fn execute(&self, config: crate::AspmState) -> Result<(), anyhow::Error> { - let alias = Input::with_theme(&ColorfulTheme::default()) - .with_prompt("Please enter an alias to give to this key") - .allow_empty(false) - .validate_with(|input: &String| match input.as_bytes().len() <= 255 { - true => Ok(()), - false => Err("Alias must not be longer than 255 characters!"), - }) - .interact() - .context("Unable to prompt on stderr")?; + async fn execute(&self, state: crate::AspmState) -> Result<(), anyhow::Error> { + let alias = if let Some(alias) = &self.key_alias { + alias.clone() + } else { + Input::with_theme(&ColorfulTheme::default()) + .with_prompt("Please enter an alias to give to this key") + .allow_empty(false) + .interact() + .context("Unable to prompt on stderr")? + }; let key_password = std::env::var("KEY_PASSWORD").or_else(|_| { Password::with_theme(&ColorfulTheme::default()) @@ -70,26 +72,20 @@ impl AspmSubcommand for KeysGenerateCommand { .export_encrypted(aes_key) .context("Unable to derive the encryption key")?; - let txn = config - .db - .begin_write() - .context("Unable to open the database for writing")?; - { - let mut table = txn.open_table(KEYS_TABLE)?; - table - .insert( - key.fingerprint.as_str(), - KeysTableValue { - key: encrypted, - alias: alias - .try_into() - .context("alias must be less than or equal to 255 characters")?, - key_type: key.key_type, - }, - ) - .context("Unable to write to database")?; + // Write to db + let entry = keys::ActiveModel { + fingerprint: ActiveValue::Set(key.fingerprint.clone()), + key_type: ActiveValue::Set(key.key_type.into()), + alias: ActiveValue::Set(alias), + encrypted: ActiveValue::Set(encrypted), + }; + let res = keys::Entity::insert(entry) + .exec(&state.db) + .await + .context("Unable to add key to database")?; + if res.last_insert_id != key.fingerprint { + bail!("The key was unable to be saved to the database") } - txn.commit().context("Unable to write to database")?; printdoc! { " diff --git a/src/commands/keys/list.rs b/src/commands/keys/list.rs index 6cb4f5c..5891997 100644 --- a/src/commands/keys/list.rs +++ b/src/commands/keys/list.rs @@ -1,24 +1,23 @@ use anstyle::{AnsiColor, Reset, Style as Anstyle}; use anyhow::Context; +use asp::keys::AspKeyType; use clap::Parser; use indoc::printdoc; -use redb::ReadableTable; +use sea_orm::EntityTrait; -use crate::{commands::AspmSubcommand, db::KEYS_TABLE}; +use crate::{commands::AspmSubcommand, entities::keys}; /// A command to list all saved keys, along with their fingerprints and types #[derive(Parser, Debug)] pub struct KeysListCommand; +#[async_trait::async_trait] impl AspmSubcommand for KeysListCommand { - fn execute(&self, state: crate::AspmState) -> Result<(), anyhow::Error> { - let txn = state - .db - .begin_read() - .context("Unable to start db read transaction")?; - let table = txn.open_table(KEYS_TABLE)?; - let iter = table.iter().context("Unable to read table entries")?; - let entries: Vec<_> = iter.collect(); + async fn execute(&self, state: crate::AspmState) -> Result<(), anyhow::Error> { + let entries = keys::Entity::find() + .all(&state.db) + .await + .context("Unable to read keys from database")?; // Construct styles let reset = Reset::default().render(); @@ -44,18 +43,15 @@ impl AspmSubcommand for KeysListCommand { n = entries.len(), ); for entry in entries.iter() { - if let Ok((fingerprint, value)) = entry { - let value = value.value(); - printdoc! { - " - {alias_style}{alias}:{reset} - {key_style}Fingerprint{reset} {value_style}{fingerprint}{reset} - {key_style}Key Type{reset} {value_style}{key_type:?}{reset} - ", - fingerprint = fingerprint.value(), - key_type = value.key_type, - alias = value.alias - } + printdoc! { + " + {alias_style}{alias}:{reset} + {key_style}Fingerprint{reset} {value_style}{fingerprint}{reset} + {key_style}Key Type{reset} {value_style}{key_type:?}{reset} + ", + fingerprint = entry.fingerprint, + key_type = TryInto::::try_into(entry.key_type).context("Unable to get key type from database")?, + alias = entry.alias } } diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 1fa673b..d185605 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -4,6 +4,7 @@ use clap::Parser; use crate::AspmState; +#[async_trait::async_trait] pub trait AspmSubcommand: Parser { - fn execute(&self, state: AspmState) -> Result<(), anyhow::Error>; + async fn execute(&self, state: AspmState) -> Result<(), anyhow::Error>; } diff --git a/src/db.rs b/src/db.rs deleted file mode 100644 index ed7766e..0000000 --- a/src/db.rs +++ /dev/null @@ -1,128 +0,0 @@ -use std::fmt::Display; - -use anyhow::bail; -use asp::keys::AspKeyType; -use redb::{RedbValue, TableDefinition}; - -#[derive(Debug)] -pub struct KeysTableValue { - pub alias: BoundedString, - pub key: String, - pub key_type: AspKeyType, -} - -#[derive(Debug, Clone)] -pub struct BoundedString { - inner: String, -} - -impl Display for BoundedString { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.inner) - } -} - -impl TryFrom for BoundedString { - type Error = anyhow::Error; - - fn try_from(value: String) -> Result { - if value.as_bytes().len() > 255 { - bail!("Value was too long"); - } - Ok(Self { inner: value }) - } -} - -impl Into> for BoundedString { - fn into(self) -> Vec { - self.inner.as_bytes().to_vec() - } -} - -impl RedbValue for KeysTableValue { - type SelfType<'a> = KeysTableValue; - - /// The first u8 is a length, specifying how long the alias is (therefore the alias can only be a max of 255 bytes) - /// The next bytes (bounded by the length of the first u8) is the alias - /// The next byte is a u8 representing the type of key - /// The rest of the bytes are the key - type AsBytes<'a> = Vec; - - fn fixed_width() -> Option { - None - } - - // This does panic, but I don't know if there is a better way to do it. If you manage to insert bad data into the table, good job, that is your problem - fn from_bytes<'a>(data: &'a [u8]) -> Self::SelfType<'a> - where - Self: 'a, - { - let mut iter = data.iter().map(|b| *b); - - let alias_length: usize = iter - .next() - .expect("parsing key table value failed: unable to get first byte") - .into(); - // Get alias - let alias_bytes = { - let mut vec = Vec::new(); - for _ in 0..alias_length { - vec.push( - iter.next() - .expect("parsing key table value failed: ran out of bytes on alias"), - ); - } - vec - }; - if alias_bytes.len() != alias_length { - panic!("parsing key table value failed: unable to get full alias"); - }; - // Get the type of key - let key_type_byte = iter - .next() - .expect("parsing key table value failed: unable to get the key type"); - // Get key - let key_bytes = iter.collect::>(); - // Assemble bytes into strings and struct - Self { - key: String::from_utf8(key_bytes) - .expect("parsing key table value failed: unable to decode key into string"), - alias: String::from_utf8(alias_bytes) - .expect("parsing key table value failed: unable to decode alias into string") - .try_into() - .unwrap(), - key_type: match key_type_byte { - 0 => AspKeyType::Ed25519, - 1 => AspKeyType::ES256, - _ => panic!("parsing key table value failed: unknown key type byte found"), - }, - } - } - - fn as_bytes<'a, 'b: 'a>(value: &'a Self::SelfType<'b>) -> Self::AsBytes<'a> - where - Self: 'a, - Self: 'b, - { - let key_bytes = value.key.as_bytes(); - let alias_bytes: Vec = value.alias.clone().into(); - - let mut serialized: Vec = vec![]; - serialized.push(alias_bytes.len().try_into().unwrap()); // Add the first byte (alias length) - serialized.extend_from_slice(alias_bytes.as_slice()); // Add the alias bytes - serialized.push(match value.key_type { - AspKeyType::Ed25519 => 0, - AspKeyType::ES256 => 1, - }); // Add the key type byte - serialized.extend_from_slice(key_bytes); // Add the rest of the bytes, all of which are the key - - serialized - } - - fn type_name() -> redb::TypeName { - redb::TypeName::new("aspm::KeysTableValue") - } -} - -/// A table to contain saved keys -pub const KEYS_TABLE: TableDefinition<&str, KeysTableValue> = TableDefinition::new("claims"); diff --git a/src/entities/keys.rs b/src/entities/keys.rs new file mode 100644 index 0000000..fb7a364 --- /dev/null +++ b/src/entities/keys.rs @@ -0,0 +1,18 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "keys")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub fingerprint: String, + pub key_type: i32, + pub alias: String, + pub encrypted: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/entities/mod.rs b/src/entities/mod.rs new file mode 100644 index 0000000..37aba69 --- /dev/null +++ b/src/entities/mod.rs @@ -0,0 +1,5 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +pub mod prelude; + +pub mod keys; diff --git a/src/entities/prelude.rs b/src/entities/prelude.rs new file mode 100644 index 0000000..bf7fa3f --- /dev/null +++ b/src/entities/prelude.rs @@ -0,0 +1,3 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +pub use super::keys::Entity as Keys; diff --git a/src/main.rs b/src/main.rs index 000a366..26902a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,15 @@ mod commands; -mod db; +mod entities; +mod migrations; use anstyle::{AnsiColor, Color as AnstyleColor, Style as Anstyle}; use anyhow::Context; use app_dirs2::{AppDataType, AppInfo}; use clap::{Parser, Subcommand}; use commands::{keys::KeysSubcommands, AspmSubcommand}; -use redb::Database; +use migrations::Migrator; +use sea_orm::{Database, DatabaseConnection}; +use sea_orm_migration::{MigratorTrait, SchemaManager}; use thiserror::Error; use std::path::PathBuf; @@ -15,11 +18,12 @@ const APP_INFO: AppInfo = AppInfo { name: env!("CARGO_CRATE_NAME"), author: "Ty", }; +const DATABASE_URL: &str = "sqlite://DB_PATH?mode=rwc"; #[derive(Debug)] pub struct AspmState { pub data_dir: PathBuf, - pub db: Database, + pub db: DatabaseConnection, } #[derive(Parser)] @@ -73,8 +77,9 @@ pub enum AspmSubcommands { Keys(commands::keys::KeysSubcommand), } -fn main() { - match cli() { +#[tokio::main] +async fn main() { + match cli().await { Err(e) => { eprintln!("An error occurred while running that command:\n{e}"); } @@ -82,7 +87,7 @@ fn main() { } } -fn cli() -> Result<(), anyhow::Error> { +async fn cli() -> Result<(), anyhow::Error> { let parsed = AspmCommand::parse(); // Check the data dir (read and write) @@ -96,14 +101,24 @@ fn cli() -> Result<(), anyhow::Error> { std::fs::read_dir(&data_dir).or(Err(AspmError::DataDirReadError))?; // Construct the database in the dir - let mut db = Database::create({ + let db = Database::connect(DATABASE_URL.replace("DB_PATH", &{ let mut new = data_dir.clone(); - new.push("db.redb"); - new - }) - .or(Err(AspmError::DatabaseCreateError))?; - db.check_integrity() - .context("Unable to check database integrity")?; + new.push("db.sqlite"); + new.to_str() + .context("Unable to parse database path into string") + .map(|s| s.to_string()) + }?)) + .await + .context("Unable to open database")?; + + let schema_manager = SchemaManager::new(&db); + Migrator::up(&db, None) + .await + .context("Unable to migrate database")?; + assert!(schema_manager + .has_table("keys") + .await + .context("Unable to check database for keys table")?); // Make the state let state = AspmState { data_dir, db }; @@ -111,9 +126,9 @@ fn cli() -> Result<(), anyhow::Error> { // Call the subcommand match &parsed.subcommand { AspmSubcommands::Keys(subcommand) => match &subcommand.subcommand { - KeysSubcommands::Generate(subcommand) => subcommand.execute(state), - KeysSubcommands::List(subcommand) => subcommand.execute(state), - KeysSubcommands::Export(subcommand) => subcommand.execute(state), + KeysSubcommands::Generate(subcommand) => subcommand.execute(state).await, + KeysSubcommands::List(subcommand) => subcommand.execute(state).await, + KeysSubcommands::Export(subcommand) => subcommand.execute(state).await, }, } } @@ -122,8 +137,6 @@ fn cli() -> Result<(), anyhow::Error> { enum AspmError { #[error("The data directory was unable to be created, is it correct, and does the current user have permission to create it?")] DataDirCreateError, - #[error("The database was unable to be created, is the data dir correct, and does the current user have permission to modify it?")] - DatabaseCreateError, #[error("The data directory was unable to be read, is it correct, and does the current user have permission to read it?")] DataDirReadError, #[error("An unknown internal error occurred, please report this to the developer")] diff --git a/src/migrations/m_20230701_000001_create_keys_table.rs b/src/migrations/m_20230701_000001_create_keys_table.rs new file mode 100644 index 0000000..521b811 --- /dev/null +++ b/src/migrations/m_20230701_000001_create_keys_table.rs @@ -0,0 +1,48 @@ +use sea_orm_migration::prelude::*; + +pub struct Migration; + +impl MigrationName for Migration { + fn name(&self) -> &str { + "m_20230701_000001_create_keys_table" + } +} + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + // Define how to apply this migration: Create the Bakery table. + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .create_table( + Table::create() + .table(Keys::Table) + .col( + ColumnDef::new(Keys::Fingerprint) + .string_len(26) + .not_null() + .primary_key(), + ) + .col(ColumnDef::new(Keys::KeyType).integer().not_null()) + .col(ColumnDef::new(Keys::Alias).string().not_null()) + .col(ColumnDef::new(Keys::Encrypted).string().not_null()) + .to_owned(), + ) + .await + } + + // Define how to rollback this migration: Drop the Bakery table. + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .drop_table(Table::drop().table(Keys::Table).to_owned()) + .await + } +} + +#[derive(Iden)] +enum Keys { + Table, + Fingerprint, + KeyType, + Alias, + Encrypted, +} diff --git a/src/migrations/mod.rs b/src/migrations/mod.rs new file mode 100644 index 0000000..19b82b1 --- /dev/null +++ b/src/migrations/mod.rs @@ -0,0 +1,11 @@ +mod m_20230701_000001_create_keys_table; + +use sea_orm_migration::prelude::*; + +pub struct Migrator; + +impl MigratorTrait for Migrator { + fn migrations() -> Vec> { + vec![Box::new(m_20230701_000001_create_keys_table::Migration)] + } +}