diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index da2b227a6..4a0facdf6 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -15,7 +15,7 @@ jobs: - name: Start database run: docker compose -f dev.docker-compose.yml up -d - name: Migrate database - run: cd editor-server && cargo prisma migrate dev --skip-generate --name init + run: cd editor-server && set -a && source .env && set +a && cargo run -p migration -- up - name: Build and clippy check run: cargo clippy --manifest-path ./editor-server/Cargo.toml - name: fmt check @@ -29,4 +29,4 @@ jobs: - name: build test and clippy check run: cargo clippy --manifest-path ./file-server/Cargo.toml - name: fmt check - run: cargo fmt --manifest-path ./file-server/Cargo.toml \ No newline at end of file + run: cargo fmt --manifest-path ./file-server/Cargo.toml diff --git a/README.md b/README.md index 1c4dfaf11..6ffae7801 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,9 @@ docker compose -f dev.docker-compose.yml up -d migrate the database ```sh -# in Lightdance-Editor/editor-server -cargo prisma migrate dev --skip-generate --name init +# in Lightdance-Editor/editor-server/sea-orm +DATABASE_URL="mysql://root:password@localhost:3306/editor" sea-orm-cli migrate up +DATABASE_URL="mysql://root:password@localhost:3306/editor" sea-orm-cli generate entity -o sea-orm/src/entity ``` #### Install the dependencies @@ -139,7 +140,8 @@ migrate the database ```sh # in Lightdance-Editor/editor-server -cargo prisma migrate dev --skip-generate --name init +DATABASE_URL="mysql://root:password@localhost:3306/editor" sea-orm-cli migrate up +DATABASE_URL="mysql://root:password@localhost:3306/editor" sea-orm-cli generate entity -o sea-orm/src/entity ``` Start all services diff --git a/editor-server/.cargo/config.toml b/editor-server/.cargo/config.toml index 1f5bf2d11..b7b36ba72 100644 --- a/editor-server/.cargo/config.toml +++ b/editor-server/.cargo/config.toml @@ -1,2 +1,2 @@ [alias] -prisma = "run -p prisma --" +migrate = "run -p migration --" diff --git a/editor-server/.env.development b/editor-server/.env.development index 319d63f17..811d575cf 100644 --- a/editor-server/.env.development +++ b/editor-server/.env.development @@ -8,8 +8,7 @@ DATABASE_URL="mysql://root:password@localhost:3306/editor" EXPIRATION_TIME_HOURS=24 AUTH0_DOMAIN=dev-fz1bb1rnqkxgp6wr.us.auth0.com AUTH0_CLIENT_ID=7xfl2SdpyQoDLFGJQrLv0u5oi7jmgKUw -AUTH0_CLIENT_SECRET= + AUTH0_TEST_USERNAME=test_user2 -AUTH0_TEST_PASSWORD=fOObAR123456 AUTH0_TEST_USER_ID=2 -AUTH0_TEST_TOKEN=testToken +AUTH0_TEST_TOKEN=testToken \ No newline at end of file diff --git a/editor-server/.env.production b/editor-server/.env.production index e46edfb4e..220f3da4e 100644 --- a/editor-server/.env.production +++ b/editor-server/.env.production @@ -8,4 +8,4 @@ DATABASE_URL="mysql://root:password@mysql:3306/editor" EXPIRATION_TIME_HOURS=24 AUTH0_DOMAIN=dev-fz1bb1rnqkxgp6wr.us.auth0.com AUTH0_CLIENT_ID=7xfl2SdpyQoDLFGJQrLv0u5oi7jmgKUw -AUTH0_CLIENT_SECRET= +AUTH0_CLIENT_SECRET= \ No newline at end of file diff --git a/editor-server/.gitignore b/editor-server/.gitignore index ae3b23b6a..2f7896d1d 100644 --- a/editor-server/.gitignore +++ b/editor-server/.gitignore @@ -1,7 +1 @@ -src/prisma/ target/ - -prisma/migrations -schema.graphql - -src/prisma diff --git a/editor-server/Cargo.lock b/editor-server/Cargo.lock index c5060bfdc..caa647f21 100644 --- a/editor-server/Cargo.lock +++ b/editor-server/Cargo.lock @@ -40,21 +40,18 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] -name = "aho-corasick" -version = "1.1.3" +name = "aliasable" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" [[package]] name = "allocator-api2" @@ -78,10 +75,54 @@ dependencies = [ ] [[package]] -name = "anyhow" -version = "1.0.97" +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] [[package]] name = "arc-swap" @@ -108,16 +149,73 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] -name = "ascii" +name = "ascii_utils" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" +checksum = "71938f30533e4d95a6d17aa530939da3842c2ab6f4f84b9dae68447e4129f74a" [[package]] -name = "ascii_utils" -version = "0.9.3" +name = "async-attributes" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71938f30533e4d95a6d17aa530939da3842c2ab6f4f84b9dae68447e4129f74a" +checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener 2.5.3", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497c00e0fd83a72a79a39fcbd8e3e2f055d6f6c7e025f3b3d91f4f8e76527fb8" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand 2.3.0", + "futures-lite 2.6.1", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" +dependencies = [ + "async-channel 2.5.0", + "async-executor", + "async-io 2.6.0", + "async-lock 3.4.2", + "blocking", + "futures-lite 2.6.1", + "once_cell", + "tokio", +] [[package]] name = "async-graphql" @@ -130,15 +228,15 @@ dependencies = [ "async-graphql-value", "async-stream", "async-trait", - "base64 0.22.1", + "base64", "bytes", "fast_chemail", "fnv", "futures-timer", "futures-util", "handlebars", - "http 1.2.0", - "indexmap 2.7.1", + "http", + "indexmap", "mime", "multer", "num-traits", @@ -207,11 +305,96 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "741110dda927420a28fbc1c310543d3416f789a6ba96859c2c265843a0a96887" dependencies = [ "bytes", - "indexmap 2.7.1", + "indexmap", "serde", "serde_json", ] +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-lite 1.13.0", + "log", + "parking", + "polling 2.8.0", + "rustix 0.37.28", + "slab", + "socket2 0.4.10", + "waker-fn", +] + +[[package]] +name = "async-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" +dependencies = [ + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.6.1", + "parking", + "polling 3.11.0", + "rustix 1.1.3", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f7f2596bd5b78a9fec8088ccd89180d7f9f55b94b0576823bbbdc72ee8311" +dependencies = [ + "event-listener 5.4.0", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-std" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c8e079a4ab67ae52b7403632e4618815d6db36d2a010cfe41b02c1b1578f93b" +dependencies = [ + "async-attributes", + "async-channel 1.9.0", + "async-global-executor", + "async-io 2.6.0", + "async-lock 3.4.2", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite 2.6.1", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + [[package]] name = "async-stream" version = "0.3.6" @@ -234,6 +417,12 @@ dependencies = [ "syn 2.0.99", ] +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + [[package]] name = "async-trait" version = "0.1.87" @@ -254,15 +443,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "atomic-shim" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cd4b51d303cf3501c301e8125df442128d3c6d7c69f71b27833d253de47e77" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "atomic-waker" version = "1.1.2" @@ -283,14 +463,14 @@ checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" dependencies = [ "axum-core", "axum-macros", - "base64 0.22.1", + "base64", "bytes", "form_urlencoded", "futures-util", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", - "hyper 1.6.0", + "hyper", "hyper-util", "itoa", "matchit", @@ -305,7 +485,7 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", "tokio-tungstenite", "tower", @@ -322,13 +502,13 @@ checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733" dependencies = [ "bytes", "futures-util", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.2", + "sync_wrapper", "tower-layer", "tower-service", "tracing", @@ -345,8 +525,8 @@ dependencies = [ "bytes", "cookie", "futures-util", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", "mime", "pin-project-lite", @@ -382,40 +562,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "base-x" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" - -[[package]] -name = "base36" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9c26bddc1271f7112e5ec797e8eeba6de2de211c1488e506b9500196dbf77c5" -dependencies = [ - "base-x", - "failure", -] - -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" @@ -434,7 +580,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b1866ecef4f2d06a0bb77880015fdf2b89e25a1c2e5addacb87e459c86dc67e" dependencies = [ - "base64 0.22.1", + "base64", "blowfish", "getrandom 0.2.15", "subtle", @@ -443,32 +589,16 @@ dependencies = [ [[package]] name = "bigdecimal" -version = "0.3.1" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" +checksum = "4d6867f1565b3aad85681f1015055b087fcfd840d6aeee6eee7f2da317603695" dependencies = [ + "autocfg", + "libm", "num-bigint", "num-integer", "num-traits", -] - -[[package]] -name = "bindgen" -version = "0.59.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" -dependencies = [ - "bitflags 1.3.2", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", + "serde", ] [[package]] @@ -516,6 +646,19 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blocking" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83f8d02be6967315521be875afa792a316e28d57b5a2d401897e2a7921b7f21" +dependencies = [ + "async-channel 2.5.0", + "async-task", + "futures-io", + "futures-lite 2.6.1", + "piper", +] + [[package]] name = "blowfish" version = "0.9.1" @@ -564,21 +707,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8" -[[package]] -name = "builtin-psl-connectors" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "connection-string", - "either", - "enumflags2", - "indoc", - "lsp-types", - "once_cell", - "psl-core", - "regex", -] - [[package]] name = "bumpalo" version = "3.17.0" @@ -633,15 +761,6 @@ dependencies = [ "shlex", ] -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - [[package]] name = "cfg-if" version = "1.0.0" @@ -662,11 +781,9 @@ checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "android-tzdata", "iana-time-zone", - "js-sys", "num-traits", "serde", - "wasm-bindgen", - "windows-link", + "windows-link 0.1.0", ] [[package]] @@ -680,48 +797,60 @@ dependencies = [ ] [[package]] -name = "clang-sys" -version = "1.8.1" +name = "clap" +version = "4.5.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" dependencies = [ - "glob", - "libc", - "libloading", + "clap_builder", + "clap_derive", ] [[package]] -name = "cmake" -version = "0.1.54" +name = "clap_builder" +version = "4.5.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" +checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" dependencies = [ - "cc", + "anstream", + "anstyle", + "clap_lex", + "strsim", ] [[package]] -name = "colored" -version = "2.2.0" +name = "clap_derive" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" dependencies = [ - "lazy_static", - "windows-sys 0.59.0", + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.99", ] [[package]] -name = "combine" -version = "3.8.1" +name = "clap_lex" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" +checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32" + +[[package]] +name = "cmake" +version = "0.1.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" dependencies = [ - "ascii", - "byteorder", - "either", - "memchr", - "unreachable", + "cc", ] +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + [[package]] name = "combine" version = "4.6.7" @@ -745,15 +874,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "connection-string" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97faeec45f49581c458f8bf81992c5e3ec17d82cda99f59d3cea14eff62698d" -dependencies = [ - "wasm-bindgen", -] - [[package]] name = "console" version = "0.15.11" @@ -773,12 +893,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "convert_case" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8" - [[package]] name = "cookie" version = "0.18.1" @@ -840,112 +954,35 @@ dependencies = [ ] [[package]] -name = "crossbeam" -version = "0.8.4" +name = "crossbeam-queue" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-epoch", - "crossbeam-queue", "crossbeam-utils", ] [[package]] -name = "crossbeam-channel" -version = "0.5.14" +name = "crossbeam-utils" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" -dependencies = [ - "crossbeam-utils", -] +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] -name = "crossbeam-deque" -version = "0.8.6" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", + "generic-array", + "typenum", ] [[package]] -name = "crossbeam-epoch" -version = "0.9.18" +name = "darling" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-queue" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "cuid" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7fe01ebbba358b9af4850d1a2b16d45f765137398e34134643790f19dc935a0" -dependencies = [ - "base36", - "cuid-util", - "cuid2", - "hostname", - "num", - "once_cell", - "rand 0.8.5", - "uuid", -] - -[[package]] -name = "cuid-util" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d59a706635108a7e8eaae7ec8e6154504fafa4a415ef38690d94fccea051757" - -[[package]] -name = "cuid2" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc4ec2422180444acb04e5dda013369c9860fe66e8f558aa8c3f265ad195d3" -dependencies = [ - "cuid-util", - "getrandom 0.2.15", - "num", - "rand 0.8.5", - "sha3", - "web-time", -] - -[[package]] -name = "darling" -version = "0.20.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -1000,27 +1037,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] -name = "derive_utils" -version = "0.15.0" +name = "derive_more" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccfae181bab5ab6c5478b2ccb69e4c68a02f8c3ec72f6616bfec9dbc599d2ee0" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" dependencies = [ "proc-macro2", "quote", + "rustc_version", "syn 2.0.99", + "unicode-xid", ] [[package]] -name = "diagnostics" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" +name = "derive_utils" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccfae181bab5ab6c5478b2ccb69e4c68a02f8c3ec72f6616bfec9dbc599d2ee0" dependencies = [ - "colored", - "indoc", - "pest", + "proc-macro2", + "quote", + "syn 2.0.99", ] [[package]] @@ -1035,26 +1085,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "directories" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "displaydoc" version = "0.2.5" @@ -1066,39 +1096,6 @@ dependencies = [ "syn 2.0.99", ] -[[package]] -name = "dml" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "chrono", - "cuid", - "either", - "enumflags2", - "indoc", - "prisma-value", - "psl-core", - "schema-ast", - "serde", - "serde_json", - "uuid", -] - -[[package]] -name = "dmmf" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "bigdecimal", - "indexmap 1.9.3", - "prisma-models", - "psl", - "schema", - "schema-builder", - "serde", - "serde_json", -] - [[package]] name = "dotenv" version = "0.15.0" @@ -1127,12 +1124,12 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "http 1.2.0", + "http", "indicatif", - "itertools 0.14.0", + "itertools", "once_cell", "redis", - "reqwest 0.12.12", + "reqwest", "serde", "serde_json", "slab", @@ -1170,32 +1167,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "endian-type" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" - -[[package]] -name = "enumflags2" -version = "0.7.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147" -dependencies = [ - "enumflags2_derive", -] - -[[package]] -name = "enumflags2_derive" -version = "0.7.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.99", -] - [[package]] name = "equivalent" version = "1.0.2" @@ -1223,6 +1194,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + [[package]] name = "event-listener" version = "5.4.0" @@ -1235,25 +1212,13 @@ dependencies = [ ] [[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" +name = "event-listener-strategy" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure 0.12.6", + "event-listener 5.4.0", + "pin-project-lite", ] [[package]] @@ -1267,15 +1232,18 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.3.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] [[package]] -name = "fixedbitset" -version = "0.1.9" +name = "fastrand" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "flate2" @@ -1335,62 +1303,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "frunk" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "874b6a17738fc273ec753618bac60ddaeac48cb1d7684c3e7bd472e57a28b817" -dependencies = [ - "frunk_core", - "frunk_derives", - "frunk_proc_macros", - "serde", -] - -[[package]] -name = "frunk_core" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3529a07095650187788833d585c219761114005d5976185760cf794d265b6a5c" -dependencies = [ - "serde", -] - -[[package]] -name = "frunk_derives" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e99b8b3c28ae0e84b604c75f721c21dc77afb3706076af5e8216d15fd1deaae3" -dependencies = [ - "frunk_proc_macro_helpers", - "quote", - "syn 2.0.99", -] - -[[package]] -name = "frunk_proc_macro_helpers" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05a956ef36c377977e512e227dcad20f68c2786ac7a54dacece3746046fea5ce" -dependencies = [ - "frunk_core", - "proc-macro2", - "quote", - "syn 2.0.99", -] - -[[package]] -name = "frunk_proc_macros" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e86c2c9183662713fea27ea527aad20fb15fee635a71081ff91bf93df4dc51" -dependencies = [ - "frunk_core", - "frunk_proc_macro_helpers", - "quote", - "syn 2.0.99", -] - [[package]] name = "funty" version = "2.0.0" @@ -1447,7 +1359,7 @@ checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", "lock_api", - "parking_lot 0.12.3", + "parking_lot", ] [[package]] @@ -1456,6 +1368,34 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +[[package]] +name = "futures-lite" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-lite" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +dependencies = [ + "fastrand 2.3.0", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + [[package]] name = "futures-macro" version = "0.3.31" @@ -1513,17 +1453,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.15" @@ -1531,10 +1460,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi 0.11.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -1562,32 +1489,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] -name = "graphql-parser" +name = "gloo-timers" version = "0.3.0" -source = "git+https://github.com/prisma/graphql-parser#6a3f58bd879065588e710cb02b5bd30c1ce182c3" -dependencies = [ - "combine 3.8.1", - "indexmap 1.9.3", - "thiserror 1.0.69", -] - -[[package]] -name = "h2" -version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" dependencies = [ - "bytes", - "fnv", + "futures-channel", "futures-core", - "futures-sink", - "futures-util", - "http 0.2.12", - "indexmap 2.7.1", - "slab", - "tokio", - "tokio-util", - "tracing", + "js-sys", + "wasm-bindgen", ] [[package]] @@ -1601,8 +1511,8 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.2.0", - "indexmap 2.7.1", + "http", + "indexmap", "slab", "tokio", "tokio-util", @@ -1623,15 +1533,6 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] - [[package]] name = "hashbrown" version = "0.12.3" @@ -1661,6 +1562,12 @@ dependencies = [ "hashbrown 0.15.2", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "heck" version = "0.5.0" @@ -1673,6 +1580,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + [[package]] name = "hex" version = "0.4.3" @@ -1706,50 +1619,17 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "hostname" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9c7c7c8ac16c798734b8a24560c1362120597c40d5e1459f09498f8f6c8f2ba" -dependencies = [ - "cfg-if", - "libc", - "windows", -] - [[package]] name = "http" -version = "0.2.12" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", "itoa", ] -[[package]] -name = "http" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.12", - "pin-project-lite", -] - [[package]] name = "http-body" version = "1.0.1" @@ -1757,7 +1637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.2.0", + "http", ] [[package]] @@ -1768,8 +1648,8 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "pin-project-lite", ] @@ -1785,30 +1665,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "hyper" -version = "0.14.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2 0.5.8", - "tokio", - "tower-service", - "tracing", - "want", -] - [[package]] name = "hyper" version = "1.6.0" @@ -1818,9 +1674,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.8", - "http 1.2.0", - "http-body 1.0.1", + "h2", + "http", + "http-body", "httparse", "httpdate", "itoa", @@ -1837,8 +1693,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", - "http 1.2.0", - "hyper 1.6.0", + "http", + "hyper", "hyper-util", "rustls", "rustls-pki-types", @@ -1847,19 +1703,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.32", - "native-tls", - "tokio", - "tokio-native-tls 0.3.1", -] - [[package]] name = "hyper-tls" version = "0.6.0" @@ -1868,11 +1711,11 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.6.0", + "hyper", "hyper-util", "native-tls", "tokio", - "tokio-native-tls 0.3.1", + "tokio-native-tls", "tower-service", ] @@ -1885,9 +1728,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.2.0", - "http-body 1.0.1", - "hyper 1.6.0", + "http", + "http-body", + "hyper", "pin-project-lite", "socket2 0.5.8", "tokio", @@ -2063,17 +1906,6 @@ dependencies = [ "icu_properties", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - [[package]] name = "indexmap" version = "2.7.1" @@ -2099,10 +1931,15 @@ dependencies = [ ] [[package]] -name = "indoc" -version = "1.0.9" +name = "inherent" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" +checksum = "c727f80bfa4a6c6e2508d2f05b6f4bfce242030bd88ed15ae5331c5b5d30fba7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.99", +] [[package]] name = "inout" @@ -2131,6 +1968,17 @@ dependencies = [ "derive_utils", ] +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "ipnet" version = "2.11.0" @@ -2138,13 +1986,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] -name = "itertools" -version = "0.10.5" +name = "is_terminal_polyfill" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "itertools" @@ -2181,12 +2026,12 @@ dependencies = [ ] [[package]] -name = "keccak" -version = "0.1.5" +name = "kv-log-macro" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" dependencies = [ - "cpufeatures", + "log", ] [[package]] @@ -2198,100 +2043,11 @@ dependencies = [ "spin", ] -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - -[[package]] -name = "lexical" -version = "6.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7aefb36fd43fef7003334742cbf77b243fcd36418a1d1bdd480d613a67968f6" -dependencies = [ - "lexical-core", -] - -[[package]] -name = "lexical-core" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46" -dependencies = [ - "lexical-parse-float", - "lexical-parse-integer", - "lexical-util", - "lexical-write-float", - "lexical-write-integer", -] - -[[package]] -name = "lexical-parse-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" -dependencies = [ - "lexical-parse-integer", - "lexical-util", - "static_assertions", -] - -[[package]] -name = "lexical-parse-integer" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" -dependencies = [ - "lexical-util", - "static_assertions", -] - -[[package]] -name = "lexical-util" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5255b9ff16ff898710eb9eb63cb39248ea8a5bb036bea8085b1a767ff6c4e3fc" -dependencies = [ - "static_assertions", -] - -[[package]] -name = "lexical-write-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862" -dependencies = [ - "lexical-util", - "lexical-write-integer", - "static_assertions", -] - -[[package]] -name = "lexical-write-integer" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446" -dependencies = [ - "lexical-util", - "static_assertions", -] - [[package]] name = "libc" -version = "0.2.170" +version = "0.2.180" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" - -[[package]] -name = "libloading" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" -dependencies = [ - "cfg-if", - "windows-targets 0.52.6", -] +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" [[package]] name = "libm" @@ -2299,16 +2055,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" -[[package]] -name = "libredox" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" -dependencies = [ - "bitflags 2.9.0", - "libc", -] - [[package]] name = "libsqlite3-sys" version = "0.30.1" @@ -2331,10 +2077,10 @@ dependencies = [ ] [[package]] -name = "linked-hash-map" -version = "0.5.6" +name = "linux-raw-sys" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" @@ -2342,6 +2088,12 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +[[package]] +name = "linux-raw-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" + [[package]] name = "litemap" version = "0.7.5" @@ -2363,14 +2115,8 @@ name = "log" version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" - -[[package]] -name = "lru" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" dependencies = [ - "hashbrown 0.12.3", + "value-bag", ] [[package]] @@ -2379,37 +2125,6 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" -[[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map", -] - -[[package]] -name = "lsp-types" -version = "0.91.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2368312c59425dd133cb9a327afee65be0a633a8ce471d248e2202a48f8f68ae" -dependencies = [ - "bitflags 1.3.2", - "serde", - "serde_json", - "serde_repr", - "url", -] - -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", -] - [[package]] name = "matchers" version = "0.1.0" @@ -2442,90 +2157,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] -name = "metrics" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e52eb6380b6d2a10eb3434aec0885374490f5b82c8aaf5cd487a183c98be834" -dependencies = [ - "ahash", - "metrics-macros", -] - -[[package]] -name = "metrics" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142c53885123b68d94108295a09d4afe1a1388ed95b54d5dacd9a454753030f2" -dependencies = [ - "ahash", - "metrics-macros", -] - -[[package]] -name = "metrics-exporter-prometheus" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953cbbb6f9ba4b9304f4df79b98cdc9d14071ed93065a9fca11c00c5d9181b66" +name = "migration" +version = "0.1.0" dependencies = [ - "hyper 0.14.32", - "indexmap 1.9.3", - "ipnet", - "metrics 0.19.0", - "metrics-util 0.13.0", - "parking_lot 0.11.2", - "quanta", - "thiserror 1.0.69", + "sea-orm-migration", "tokio", - "tracing", -] - -[[package]] -name = "metrics-macros" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49e30813093f757be5cf21e50389a24dc7dbb22c49f23b7e8f51d69b508a5ffa" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "metrics-util" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65a9e83b833e1d2e07010a386b197c13aa199bbd0fca5cf69bfa147972db890a" -dependencies = [ - "aho-corasick 0.7.20", - "atomic-shim", - "crossbeam-epoch", - "crossbeam-utils", - "hashbrown 0.11.2", - "indexmap 1.9.3", - "metrics 0.18.1", - "num_cpus", - "ordered-float", - "parking_lot 0.11.2", - "quanta", - "radix_trie", - "sketches-ddsketch", -] - -[[package]] -name = "metrics-util" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1f4b69bef1e2b392b2d4a12902f2af90bb438ba4a66aa222d1023fa6561b50" -dependencies = [ - "atomic-shim", - "crossbeam-epoch", - "crossbeam-utils", - "hashbrown 0.11.2", - "metrics 0.19.0", - "num_cpus", - "parking_lot 0.11.2", - "quanta", - "sketches-ddsketch", ] [[package]] @@ -2534,12 +2170,6 @@ 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.8.5" @@ -2549,18 +2179,6 @@ dependencies = [ "adler2", ] -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", -] - [[package]] name = "mio" version = "1.0.3" @@ -2572,24 +2190,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "mobc" -version = "0.7.3" -source = "git+https://github.com/prisma/mobc?tag=1.0.6#80462c4870a2bf6aab49da15c88c021bae531da8" -dependencies = [ - "async-trait", - "futures-channel", - "futures-core", - "futures-timer", - "futures-util", - "log", - "metrics 0.18.1", - "thiserror 1.0.69", - "tokio", - "tracing", - "tracing-subscriber", -] - [[package]] name = "multer" version = "3.1.0" @@ -2599,7 +2199,7 @@ dependencies = [ "bytes", "encoding_rs", "futures-util", - "http 1.2.0", + "http", "httparse", "memchr", "mime", @@ -2619,13 +2219,13 @@ dependencies = [ "flate2", "io-enum", "libc", - "lru 0.12.5", - "mysql_common 0.34.1", + "lru", + "mysql_common", "named_pipe", - "pem 3.0.5", + "pem", "percent-encoding", "socket2 0.5.8", - "twox-hash 2.1.0", + "twox-hash", "url", ] @@ -2636,7 +2236,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deb6d9ff4094f6d58d3f892fc558e60048476213dd17dcf904b62202e9029da6" dependencies = [ "darling", - "heck", + "heck 0.5.0", "num-bigint", "proc-macro-crate", "proc-macro-error2", @@ -2648,83 +2248,15 @@ dependencies = [ ] [[package]] -name = "mysql_async" -version = "0.30.0" -source = "git+https://github.com/prisma/mysql_async?rev=e3f8bdb41d57e769412f53d0f479bf67fdcc0ee3#e3f8bdb41d57e769412f53d0f479bf67fdcc0ee3" +name = "mysql_common" +version = "0.34.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34a9141e735d5bb02414a7ac03add09522466d4db65bdd827069f76ae0850e58" dependencies = [ - "bytes", - "crossbeam", - "flate2", - "futures-core", - "futures-sink", - "futures-util", - "lazy_static", - "lru 0.7.8", - "mio 0.8.11", - "mysql_common 0.29.2", - "native-tls", - "once_cell", - "pem 1.1.1", - "percent-encoding", - "pin-project", - "serde", - "serde_json", - "socket2 0.4.10", - "thiserror 1.0.69", - "tokio", - "tokio-native-tls 0.3.0", - "tokio-util", - "twox-hash 1.6.3", - "url", -] - -[[package]] -name = "mysql_common" -version = "0.29.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9006c95034ccf7b903d955f210469119f6c3477fc9c9e7a7845ce38a3e665c2a" -dependencies = [ - "base64 0.13.1", - "bigdecimal", - "bindgen", - "bitflags 1.3.2", - "bitvec", - "byteorder", - "bytes", - "cc", - "cmake", - "crc32fast", - "flate2", - "frunk", - "lazy_static", - "lexical", - "num-bigint", - "num-traits", - "rand 0.8.5", - "regex", - "rust_decimal", - "saturating", - "serde", - "serde_json", - "sha1", - "sha2", - "smallvec", - "subprocess", - "thiserror 1.0.69", - "time", - "uuid", -] - -[[package]] -name = "mysql_common" -version = "0.34.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34a9141e735d5bb02414a7ac03add09522466d4db65bdd827069f76ae0850e58" -dependencies = [ - "base64 0.22.1", - "bitflags 2.9.0", - "btoi", - "byteorder", + "base64", + "bitflags 2.9.0", + "btoi", + "byteorder", "bytes", "cc", "cmake", @@ -2773,25 +2305,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "nibble_vec" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" -dependencies = [ - "smallvec", -] - -[[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 = "nu-ansi-term" version = "0.46.0" @@ -2802,20 +2315,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - [[package]] name = "num-bigint" version = "0.4.6" @@ -2843,15 +2342,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - [[package]] name = "num-conv" version = "0.1.0" @@ -2878,17 +2368,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -2899,16 +2378,6 @@ dependencies = [ "libm", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "number_prefix" version = "0.4.0" @@ -2930,6 +2399,12 @@ version = "1.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + [[package]] name = "openssl" version = "0.10.71" @@ -2975,39 +2450,37 @@ dependencies = [ ] [[package]] -name = "opentelemetry" -version = "0.17.0" +name = "ordered-float" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6105e89802af13fdf48c49d7646d3b533a70e536d818aae7e78ba0433d01acb8" +checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" dependencies = [ - "async-trait", - "crossbeam-channel", - "futures-channel", - "futures-executor", - "futures-util", - "js-sys", - "lazy_static", - "percent-encoding", - "pin-project", - "rand 0.8.5", - "thiserror 1.0.69", - "tokio", + "num-traits", ] [[package]] -name = "ordered-float" -version = "2.10.1" +name = "ouroboros" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +checksum = "1e0f050db9c44b97a94723127e6be766ac5c340c48f2c4bb3ffa11713744be59" dependencies = [ - "num-traits", + "aliasable", + "ouroboros_macro", + "static_assertions", ] [[package]] -name = "ordermap" -version = "0.3.5" +name = "ouroboros_macro" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" +checksum = "3c7028bdd3d43083f6d8d4d5187680d0d3560d54df4cc9d752005268b41e64d0" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.99", +] [[package]] name = "overload" @@ -3021,17 +2494,6 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" -[[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 0.8.6", -] - [[package]] name = "parking_lot" version = "0.12.3" @@ -3039,21 +2501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", - "parking_lot_core 0.9.10", -] - -[[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", + "parking_lot_core", ] [[package]] @@ -3064,23 +2512,11 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.10", + "redox_syscall", "smallvec", "windows-targets 0.52.6", ] -[[package]] -name = "parser-database" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "diagnostics", - "either", - "enumflags2", - "indexmap 1.9.3", - "schema-ast", -] - [[package]] name = "password-hash" version = "0.5.0" @@ -3092,28 +2528,13 @@ dependencies = [ "subtle", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - [[package]] name = "pem" version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3" dependencies = [ - "base64 0.22.1", + "base64", "serde", ] @@ -3178,13 +2599,12 @@ dependencies = [ ] [[package]] -name = "petgraph" -version = "0.4.13" +name = "pgvector" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" +checksum = "fc58e2d255979a31caa7cabfa7aac654af0354220719ab7a68520ae7a91e8c0b" dependencies = [ - "fixedbitset", - "ordermap", + "serde", ] [[package]] @@ -3219,6 +2639,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" +dependencies = [ + "atomic-waker", + "fastrand 2.3.0", + "futures-io", +] + [[package]] name = "pkcs1" version = "0.7.5" @@ -3246,6 +2677,36 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +[[package]] +name = "polling" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "concurrent-queue", + "libc", + "log", + "pin-project-lite", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi 0.5.2", + "pin-project-lite", + "rustix 1.1.3", + "windows-sys 0.61.2", +] + [[package]] name = "portable-atomic" version = "1.11.0" @@ -3267,87 +2728,6 @@ dependencies = [ "zerocopy 0.7.35", ] -[[package]] -name = "prisma" -version = "0.1.0" -dependencies = [ - "dotenv", - "mysql", - "prisma-client-rust-cli", -] - -[[package]] -name = "prisma-client-rust-cli" -version = "0.6.11" -source = "git+https://github.com/Brendonovich/prisma-client-rust?tag=0.6.11#3ac68d0052533d3ae0332d93a56a8ad169c2ee18" -dependencies = [ - "directories", - "flate2", - "http 0.2.12", - "prisma-client-rust-sdk", - "proc-macro2", - "quote", - "regex", - "reqwest 0.11.27", - "serde", - "serde_json", - "serde_path_to_error", - "syn 1.0.109", - "thiserror 1.0.69", -] - -[[package]] -name = "prisma-client-rust-sdk" -version = "0.6.11" -source = "git+https://github.com/Brendonovich/prisma-client-rust?tag=0.6.11#3ac68d0052533d3ae0332d93a56a8ad169c2ee18" -dependencies = [ - "convert_case", - "dml", - "dmmf", - "prisma-models", - "proc-macro2", - "psl", - "query-core", - "quote", - "request-handlers", - "serde", - "serde_json", - "serde_path_to_error", - "syn 1.0.109", - "thiserror 1.0.69", -] - -[[package]] -name = "prisma-models" -version = "0.0.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "bigdecimal", - "chrono", - "itertools 0.10.5", - "once_cell", - "prisma-value", - "psl", - "serde", - "serde_json", - "thiserror 1.0.69", -] - -[[package]] -name = "prisma-value" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "base64 0.12.3", - "bigdecimal", - "chrono", - "once_cell", - "regex", - "serde", - "serde_json", - "uuid", -] - [[package]] name = "proc-macro-crate" version = "3.3.0" @@ -3389,35 +2769,16 @@ dependencies = [ ] [[package]] -name = "psl" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ - "builtin-psl-connectors", - "dml", - "psl-core", -] - -[[package]] -name = "psl-core" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "bigdecimal", - "chrono", - "diagnostics", - "enumflags2", - "indoc", - "itertools 0.10.5", - "lsp-types", - "once_cell", - "parser-database", - "prisma-value", - "regex", - "schema-ast", - "serde", - "serde_json", - "url", + "proc-macro2", + "quote", + "syn 2.0.99", + "version_check", + "yansi", ] [[package]] @@ -3440,131 +2801,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "quaint" -version = "0.2.0-alpha.13" -source = "git+https://github.com/Brendonovich/quaint?tag=0.6.5#c502995f5e9dd4a86d80fa27f63e641bd6bbc6f2" -dependencies = [ - "async-trait", - "base64 0.12.3", - "bigdecimal", - "chrono", - "connection-string", - "futures", - "hex", - "lru-cache", - "metrics 0.18.1", - "mobc", - "mysql_async", - "num_cpus", - "percent-encoding", - "serde_json", - "sqlformat", - "thiserror 1.0.69", - "tokio", - "tracing", - "tracing-core", - "url", - "uuid", -] - -[[package]] -name = "quanta" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20afe714292d5e879d8b12740aa223c6a88f118af41870e8b6196e39a02238a8" -dependencies = [ - "crossbeam-utils", - "libc", - "mach", - "once_cell", - "raw-cpuid", - "wasi 0.10.2+wasi-snapshot-preview1", - "web-sys", - "winapi", -] - -[[package]] -name = "query-connector" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "anyhow", - "async-trait", - "chrono", - "futures", - "indexmap 1.9.3", - "itertools 0.10.5", - "prisma-models", - "prisma-value", - "serde", - "serde_json", - "thiserror 1.0.69", - "user-facing-errors", - "uuid", -] - -[[package]] -name = "query-core" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "async-trait", - "base64 0.12.3", - "bigdecimal", - "chrono", - "connection-string", - "crossbeam-queue", - "cuid", - "enumflags2", - "futures", - "indexmap 1.9.3", - "itertools 0.10.5", - "lazy_static", - "lru 0.7.8", - "once_cell", - "opentelemetry", - "parking_lot 0.12.3", - "petgraph", - "pin-utils", - "prisma-models", - "prisma-value", - "psl", - "query-connector", - "query-engine-metrics", - "schema", - "schema-builder", - "serde", - "serde_json", - "sql-query-connector", - "thiserror 1.0.69", - "tokio", - "tracing", - "tracing-futures", - "tracing-opentelemetry", - "tracing-subscriber", - "url", - "user-facing-errors", - "uuid", -] - -[[package]] -name = "query-engine-metrics" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "metrics 0.18.1", - "metrics-exporter-prometheus", - "metrics-util 0.12.1", - "once_cell", - "parking_lot 0.12.3", - "serde", - "serde_json", - "tracing", - "tracing-futures", - "tracing-subscriber", -] - [[package]] name = "quote" version = "1.0.39" @@ -3580,29 +2816,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" -[[package]] -name = "radix_trie" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" -dependencies = [ - "endian-type", - "nibble_vec", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] - [[package]] name = "rand" version = "0.8.5" @@ -3625,16 +2838,6 @@ dependencies = [ "zerocopy 0.8.22", ] -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - [[package]] name = "rand_chacha" version = "0.3.1" @@ -3655,15 +2858,6 @@ dependencies = [ "rand_core 0.9.3", ] -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - [[package]] name = "rand_core" version = "0.6.4" @@ -3682,24 +2876,6 @@ dependencies = [ "getrandom 0.3.1", ] -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "raw-cpuid" -version = "10.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redis" version = "0.29.1" @@ -3708,7 +2884,7 @@ checksum = "8034fb926579ff49d3fe58d288d5dcb580bf11e9bccd33224b45adebf0fd0c23" dependencies = [ "arc-swap", "bytes", - "combine 4.6.7", + "combine", "futures-util", "itoa", "num-bigint", @@ -3722,15 +2898,6 @@ dependencies = [ "url", ] -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.5.10" @@ -3740,26 +2907,15 @@ dependencies = [ "bitflags 2.9.0", ] -[[package]] -name = "redox_users" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" -dependencies = [ - "getrandom 0.2.15", - "libredox", - "thiserror 1.0.69", -] - [[package]] name = "regex" -version = "1.11.1" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ - "aho-corasick 1.1.3", + "aho-corasick", "memchr", - "regex-automata 0.4.9", + "regex-automata 0.4.13", "regex-syntax 0.8.5", ] @@ -3774,11 +2930,11 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ - "aho-corasick 1.1.3", + "aho-corasick", "memchr", "regex-syntax 0.8.5", ] @@ -3804,86 +2960,24 @@ dependencies = [ "bytecheck", ] -[[package]] -name = "request-handlers" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "bigdecimal", - "connection-string", - "dmmf", - "futures", - "graphql-parser", - "indexmap 1.9.3", - "itertools 0.10.5", - "psl", - "query-core", - "serde", - "serde_json", - "thiserror 1.0.69", - "tracing", - "url", - "user-facing-errors", -] - -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.32", - "hyper-tls 0.5.0", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls-pemfile 1.0.4", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration 0.5.1", - "tokio", - "tokio-native-tls 0.3.1", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - [[package]] name = "reqwest" version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" dependencies = [ - "base64 0.22.1", + "base64", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2 0.4.8", - "http 1.2.0", - "http-body 1.0.1", + "h2", + "http", + "http-body", "http-body-util", - "hyper 1.6.0", + "hyper", "hyper-rustls", - "hyper-tls 0.6.0", + "hyper-tls", "hyper-util", "ipnet", "js-sys", @@ -3893,14 +2987,14 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile 2.2.0", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.2", - "system-configuration 0.6.1", + "sync_wrapper", + "system-configuration", "tokio", - "tokio-native-tls 0.3.1", + "tokio-native-tls", "tower", "tower-service", "url", @@ -3996,10 +3090,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] -name = "rustc-hash" -version = "1.1.0" +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.37.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "519165d378b97752ca44bbe15047d5d3409e875f39327546b42ac81d7e18c1b6" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] [[package]] name = "rustix" @@ -4010,10 +3121,23 @@ dependencies = [ "bitflags 2.9.0", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.4.15", "windows-sys 0.59.0", ] +[[package]] +name = "rustix" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" +dependencies = [ + "bitflags 2.9.0", + "errno", + "libc", + "linux-raw-sys 0.11.0", + "windows-sys 0.61.2", +] + [[package]] name = "rustls" version = "0.23.23" @@ -4027,15 +3151,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - [[package]] name = "rustls-pemfile" version = "2.2.0" @@ -4090,43 +3205,174 @@ dependencies = [ ] [[package]] -name = "schema" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sea-bae" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f694a6ab48f14bc063cfadff30ab551d3c7e46d8f81836c51989d548f44a2a25" +dependencies = [ + "heck 0.4.1", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.99", +] + +[[package]] +name = "sea-orm" +version = "1.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d945f62558fac19e5988680d2fdf747b734c2dbc6ce2cb81ba33ed8dde5b103" +dependencies = [ + "async-stream", + "async-trait", + "bigdecimal", + "chrono", + "derive_more", + "futures-util", + "log", + "ouroboros", + "pgvector", + "rust_decimal", + "sea-orm-macros", + "sea-query", + "sea-query-binder", + "serde", + "serde_json", + "sqlx", + "strum", + "thiserror 2.0.12", + "time", + "tracing", + "url", + "uuid", +] + +[[package]] +name = "sea-orm-cli" +version = "1.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c94492e2ab6c045b4cc38013809ce255d14c3d352c9f0d11e6b920e2adc948ad" +dependencies = [ + "async-std", + "chrono", + "clap", + "dotenvy", + "glob", + "regex", + "sea-schema", + "sqlx", + "tracing", + "tracing-subscriber", + "url", +] + +[[package]] +name = "sea-orm-macros" +version = "1.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c2e64a50a9cc8339f10a27577e10062c7f995488e469f2c95762c5ee847832" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "sea-bae", + "syn 2.0.99", + "unicode-ident", +] + +[[package]] +name = "sea-orm-migration" +version = "1.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7315c0cadb7e60fb17ee2bb282aa27d01911fc2a7e5836ec1d4ac37d19250bb4" +dependencies = [ + "async-trait", + "clap", + "dotenvy", + "sea-orm", + "sea-orm-cli", + "sea-schema", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "sea-query" +version = "0.32.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a5d1c518eaf5eda38e5773f902b26ab6d5e9e9e2bb2349ca6c64cf96f80448c" +dependencies = [ + "bigdecimal", + "chrono", + "inherent", + "ordered-float", + "rust_decimal", + "sea-query-derive", + "serde_json", + "time", + "uuid", +] + +[[package]] +name = "sea-query-binder" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0019f47430f7995af63deda77e238c17323359af241233ec768aba1faea7608" dependencies = [ - "once_cell", - "prisma-models", - "psl", + "bigdecimal", + "chrono", + "rust_decimal", + "sea-query", + "serde_json", + "sqlx", + "time", + "uuid", ] [[package]] -name = "schema-ast" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" +name = "sea-query-derive" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae0cbad6ab996955664982739354128c58d16e126114fe88c2a493642502aab" dependencies = [ - "diagnostics", - "pest", - "pest_derive", + "darling", + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.99", + "thiserror 2.0.12", ] [[package]] -name = "schema-builder" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" +name = "sea-schema" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2239ff574c04858ca77485f112afea1a15e53135d3097d0c86509cef1def1338" dependencies = [ - "itertools 0.10.5", - "lazy_static", - "once_cell", - "prisma-models", - "psl", - "schema", + "futures", + "sea-query", + "sea-query-binder", + "sea-schema-derive", + "sqlx", ] [[package]] -name = "scopeguard" -version = "1.2.0" +name = "sea-schema-derive" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +checksum = "debdc8729c37fdbf88472f97fd470393089f997a909e535ff67c544d18cfccf0" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.99", +] [[package]] name = "seahash" @@ -4134,6 +3380,17 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "seaorm" +version = "0.1.0" +dependencies = [ + "dotenv", + "migration", + "mysql", + "sea-orm", + "tokio", +] + [[package]] name = "security-framework" version = "2.11.1" @@ -4157,6 +3414,12 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + [[package]] name = "serde" version = "1.0.218" @@ -4183,7 +3446,6 @@ version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ - "indexmap 2.7.1", "itoa", "memchr", "ryu", @@ -4200,17 +3462,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_repr" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.99", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -4251,16 +3502,6 @@ dependencies = [ "digest", ] -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest", - "keccak", -] - [[package]] name = "sharded-slab" version = "0.1.7" @@ -4301,12 +3542,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" -[[package]] -name = "sketches-ddsketch" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04d2ecae5fcf33b122e2e6bd520a57ccf152d2dde3b38c71039df1a6867264ee" - [[package]] name = "slab" version = "0.4.9" @@ -4364,53 +3599,11 @@ dependencies = [ "der", ] -[[package]] -name = "sql-query-connector" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "anyhow", - "async-trait", - "bigdecimal", - "chrono", - "cuid", - "futures", - "itertools 0.10.5", - "once_cell", - "opentelemetry", - "prisma-models", - "prisma-value", - "psl", - "quaint", - "query-connector", - "rand 0.7.3", - "serde", - "serde_json", - "socket2 0.4.10", - "thiserror 1.0.69", - "tokio", - "tracing", - "tracing-futures", - "tracing-opentelemetry", - "user-facing-errors", - "uuid", -] - -[[package]] -name = "sqlformat" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bba3a93db0cc4f7bdece8bb09e77e2e785c20bfebf79eb8340ed80708048790" -dependencies = [ - "nom", - "unicode_categories", -] - [[package]] name = "sqlx" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4410e73b3c0d8442c5f99b425d7a435b5ee0ae4167b3196771dd3f7a01be745f" +checksum = "1fefb893899429669dcdd979aff487bd78f4064e5e7907e4269081e0ef7d97dc" dependencies = [ "sqlx-core", "sqlx-macros", @@ -4421,43 +3614,51 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a007b6936676aa9ab40207cde35daab0a04b823be8ae004368c0793b96a61e0" +checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6" dependencies = [ + "async-io 1.13.0", + "async-std", + "base64", + "bigdecimal", "bytes", "chrono", "crc", "crossbeam-queue", "either", - "event-listener", + "event-listener 5.4.0", "futures-core", "futures-intrusive", "futures-io", "futures-util", "hashbrown 0.15.2", "hashlink", - "indexmap 2.7.1", + "indexmap", "log", "memchr", + "native-tls", "once_cell", "percent-encoding", + "rust_decimal", "serde", "serde_json", "sha2", "smallvec", "thiserror 2.0.12", + "time", "tokio", "tokio-stream", "tracing", "url", + "uuid", ] [[package]] name = "sqlx-macros" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3112e2ad78643fef903618d78cf0aec1cb3134b019730edb039b69eaf531f310" +checksum = "a2d452988ccaacfbf5e0bdbc348fb91d7c8af5bee192173ac3636b5fb6e6715d" dependencies = [ "proc-macro2", "quote", @@ -4468,13 +3669,14 @@ dependencies = [ [[package]] name = "sqlx-macros-core" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9f90acc5ab146a99bf5061a7eb4976b573f560bc898ef3bf8435448dd5e7ad" +checksum = "19a9c1841124ac5a61741f96e1d9e2ec77424bf323962dd894bdb93f37d5219b" dependencies = [ + "async-std", "dotenvy", "either", - "heck", + "heck 0.5.0", "hex", "once_cell", "proc-macro2", @@ -4487,19 +3689,19 @@ dependencies = [ "sqlx-postgres", "sqlx-sqlite", "syn 2.0.99", - "tempfile", "tokio", "url", ] [[package]] name = "sqlx-mysql" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4560278f0e00ce64938540546f59f590d60beee33fffbd3b9cd47851e5fff233" +checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526" dependencies = [ "atoi", - "base64 0.22.1", + "base64", + "bigdecimal", "bitflags 2.9.0", "byteorder", "bytes", @@ -4524,6 +3726,7 @@ dependencies = [ "percent-encoding", "rand 0.8.5", "rsa", + "rust_decimal", "serde", "sha1", "sha2", @@ -4531,18 +3734,21 @@ dependencies = [ "sqlx-core", "stringprep", "thiserror 2.0.12", + "time", "tracing", + "uuid", "whoami", ] [[package]] name = "sqlx-postgres" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5b98a57f363ed6764d5b3a12bfedf62f07aa16e1856a7ddc2a0bb190a959613" +checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46" dependencies = [ "atoi", - "base64 0.22.1", + "base64", + "bigdecimal", "bitflags 2.9.0", "byteorder", "chrono", @@ -4560,8 +3766,10 @@ dependencies = [ "log", "md-5", "memchr", + "num-bigint", "once_cell", "rand 0.8.5", + "rust_decimal", "serde", "serde_json", "sha2", @@ -4569,15 +3777,17 @@ dependencies = [ "sqlx-core", "stringprep", "thiserror 2.0.12", + "time", "tracing", + "uuid", "whoami", ] [[package]] name = "sqlx-sqlite" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f85ca71d3a5b24e64e1d08dd8fe36c6c95c339a896cc33068148906784620540" +checksum = "c2d12fe70b2c1b4401038055f90f151b78208de1f9f89a7dbfd41587a10c3eea" dependencies = [ "atoi", "chrono", @@ -4593,8 +3803,11 @@ dependencies = [ "serde", "serde_urlencoded", "sqlx-core", + "thiserror 2.0.12", + "time", "tracing", "url", + "uuid", ] [[package]] @@ -4647,7 +3860,7 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", @@ -4692,12 +3905,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "sync_wrapper" version = "1.0.2" @@ -4707,18 +3914,6 @@ dependencies = [ "futures-core", ] -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "synstructure" version = "0.13.1" @@ -4730,17 +3925,6 @@ dependencies = [ "syn 2.0.99", ] -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys 0.5.0", -] - [[package]] name = "system-configuration" version = "0.6.1" @@ -4749,17 +3933,7 @@ checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ "bitflags 2.9.0", "core-foundation", - "system-configuration-sys 0.6.0", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", + "system-configuration-sys", ] [[package]] @@ -4785,10 +3959,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" dependencies = [ "cfg-if", - "fastrand", + "fastrand 2.3.0", "getrandom 0.3.1", "once_cell", - "rustix", + "rustix 0.38.44", "windows-sys 0.59.0", ] @@ -4916,8 +4090,8 @@ dependencies = [ "backtrace", "bytes", "libc", - "mio 1.0.3", - "parking_lot 0.12.3", + "mio", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2 0.5.8", @@ -4936,15 +4110,6 @@ dependencies = [ "syn 2.0.99", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.0" -source = "git+https://github.com/pimeys/tls?branch=vendored-openssl#6d0e6fc7a4bf6f290b1033764b47cb3f26d7fceb" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-native-tls" version = "0.3.1" @@ -5014,7 +4179,7 @@ version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ - "indexmap 2.7.1", + "indexmap", "toml_datetime", "winnow", ] @@ -5028,7 +4193,7 @@ dependencies = [ "futures-core", "futures-util", "pin-project-lite", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", "tower-layer", "tower-service", @@ -5043,8 +4208,8 @@ checksum = "403fa3b783d4b626a8ad51d766ab03cb6d2dbfc46b1c5d4448395e6628dc9697" dependencies = [ "bitflags 2.9.0", "bytes", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "pin-project-lite", "tower-layer", "tower-service", @@ -5108,17 +4273,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tracing-log" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - [[package]] name = "tracing-log" version = "0.2.0" @@ -5130,20 +4284,6 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-opentelemetry" -version = "0.17.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbbe89715c1dbbb790059e2565353978564924ee85017b5fff365c872ff6721f" -dependencies = [ - "once_cell", - "opentelemetry", - "tracing", - "tracing-core", - "tracing-log 0.1.4", - "tracing-subscriber", -] - [[package]] name = "tracing-subscriber" version = "0.3.19" @@ -5159,7 +4299,7 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log 0.2.0", + "tracing-log", ] [[package]] @@ -5176,7 +4316,7 @@ checksum = "4793cb5e56680ecbb1d843515b23b6de9a75eb04b66643e256a396d43be33c13" dependencies = [ "bytes", "data-encoding", - "http 1.2.0", + "http", "httparse", "log", "rand 0.9.0", @@ -5185,17 +4325,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "twox-hash" -version = "1.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" -dependencies = [ - "cfg-if", - "rand 0.8.5", - "static_assertions", -] - [[package]] name = "twox-hash" version = "2.1.0" @@ -5253,21 +4382,6 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" -[[package]] -name = "unicode_categories" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" - -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -dependencies = [ - "void", -] - [[package]] name = "untrusted" version = "0.9.0" @@ -5283,31 +4397,6 @@ dependencies = [ "form_urlencoded", "idna", "percent-encoding", - "serde", -] - -[[package]] -name = "user-facing-error-macros" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "user-facing-errors" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?tag=pcr-0.6.10#c4aeef82dbae310e974d6122160c7e3b5fb6df53" -dependencies = [ - "backtrace", - "indoc", - "quaint", - "serde", - "serde_json", - "tracing", - "user-facing-error-macros", ] [[package]] @@ -5328,6 +4417,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "1.15.1" @@ -5344,6 +4439,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "value-bag" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ba6f5989077681266825251a52748b8c1d8a4ad098cc37e440103d0ea717fc0" + [[package]] name = "vcpkg" version = "0.2.15" @@ -5357,10 +4458,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] -name = "void" -version = "1.0.2" +name = "waker-fn" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" [[package]] name = "want" @@ -5371,18 +4472,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -5501,7 +4590,7 @@ version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" dependencies = [ - "redox_syscall 0.5.10", + "redox_syscall", "wasite", ] @@ -5536,16 +4625,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" -dependencies = [ - "windows-core", - "windows-targets 0.52.6", -] - [[package]] name = "windows-core" version = "0.52.0" @@ -5561,6 +4640,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dccfd733ce2b1753b03b6d3c65edf020262ea35e20ccdf3e288043e6dd620e3" +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-registry" version = "0.2.0" @@ -5618,6 +4703,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link 0.2.1", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -5748,16 +4842,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "wit-bindgen-rt" version = "0.33.0" @@ -5788,6 +4872,12 @@ dependencies = [ "tap", ] +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + [[package]] name = "yoke" version = "0.7.5" @@ -5809,7 +4899,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.99", - "synstructure 0.13.1", + "synstructure", ] [[package]] @@ -5871,7 +4961,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.99", - "synstructure 0.13.1", + "synstructure", ] [[package]] diff --git a/editor-server/Cargo.toml b/editor-server/Cargo.toml index 16229bdb6..6bbe192d5 100644 --- a/editor-server/Cargo.toml +++ b/editor-server/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" edition = "2021" [workspace] -members = ["prisma"] +members = ["sea-orm", "sea-orm/migration"] [dependencies] argon2 = "0.5.3" diff --git a/editor-server/README.md b/editor-server/README.md index 3633dabfa..8d45aed4a 100644 --- a/editor-server/README.md +++ b/editor-server/README.md @@ -1,8 +1,8 @@ # Editor Server -## When `prisma.schema` changes +## When schema changes -When you change the prisma schema, you need to regenerate the prisma client code and migrate the database. +When you change the SeaORM migration, you need to re-run the migration and regenerate entities. ### 1. Spin up database @@ -11,11 +11,12 @@ When you change the prisma schema, you need to regenerate the prisma client code docker compose -f dev.docker-compose.yml up -d ``` -### 2. Migrate prisma +### 2. Migrate SeaORM ```sh -# Lightdance-Editor/editor-server -cargo prisma migrate dev --skip-generate +# Lightdance-Editor/editor-server/sea-orm +sea-orm-cli migrate up +sea-orm-cli generate entity -o src/entity ``` ### 3. Run editor-server @@ -39,17 +40,12 @@ If you have initialized the database before, and you want to get a clean databas 1. shutdown the database with `docker compose -f dev.docker-compose.yml down` 2. Delete the `data` folder -3. Delete the `editor-server/prisma/migrations` folder +3. Delete the `editor-server/sea-orm/migration/src` generated tables if you want a clean re-run (or drop and recreate the DB) 4. follow the steps above to initialize the database again ## Tip -If you want to browse the database with a GUI - -```sh -# Lightdance-Editor/editor-server -npx prisma studio -``` +If you want to browse the database with a GUI, use your preferred MySQL client (e.g. DBeaver/MySQL Workbench). ## User Management with Auth0 diff --git a/editor-server/prisma/Cargo.toml b/editor-server/prisma/Cargo.toml deleted file mode 100644 index 8c56ed9f0..000000000 --- a/editor-server/prisma/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -rust-version = "1.75.0" -name = "prisma" -version = "0.1.0" -edition = "2021" - -[dependencies] -prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.6.11", features = [ - "migrations", - "mysql", -], default-features = false } -dotenv = "0.15.0" -mysql = "26.0.0" diff --git a/editor-server/prisma/schema.prisma b/editor-server/prisma/schema.prisma deleted file mode 100644 index b36a431e2..000000000 --- a/editor-server/prisma/schema.prisma +++ /dev/null @@ -1,230 +0,0 @@ -generator client { - provider = "cargo prisma" - output = "../src/prisma" - module_path = "prisma" - client_format = "folder" -} - -datasource db { - provider = "mysql" - url = env("DATABASE_URL") -} - -model Color { - id Int @id @default(autoincrement()) - name String @unique - r Int - g Int - b Int - - // relation => not in db - control_datas ControlData[] -} - -model LEDEffectState { - id Int @id @default(autoincrement()) - effect_id Int - position Int - color_id Int - alpha Int - - // relation => not in db - effect LEDEffect @relation(fields: [effect_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - - @@unique([effect_id, position]) -} - -model LEDEffect { - id Int @id @default(autoincrement()) - name String - model_id Int - part_id Int - - // relation => not in db - editing EditingLEDEffect? - control_datas ControlData[] - states LEDEffectState[] - - model Model @relation(fields: [model_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - part Part @relation(fields: [part_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - - @@unique([name, model_id, part_id]) -} - -model EditingPositionFrame { - user_id Int @id - frame_id Int? @unique - - // relation => not in db - editingFrame PositionFrame? @relation(fields: [frame_id], references: [id], onDelete: Cascade, onUpdate: Cascade) -} - -model EditingControlFrame { - user_id Int @id @unique - frame_id Int? @unique - - // relation => not in db - editing_frame ControlFrame? @relation(fields: [frame_id], references: [id], onDelete: Cascade, onUpdate: Cascade) -} - -model EditingLEDEffect { - user_id Int @id - led_effect_id Int? @unique - - // relation => not in db - editing_led_effect LEDEffect? @relation(fields: [led_effect_id], references: [id], onDelete: Cascade, onUpdate: Cascade) -} - -model Model { - id Int @id @default(autoincrement()) - name String @unique - - // relation => not in db - dancers Dancer[] - parts Part[] - led_effect LEDEffect[] -} - -model Dancer { - id Int @id @default(autoincrement()) - name String @unique - model_id Int - - // relation => not in db - model Model @relation(fields: [model_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - - position_datas PositionData[] - control_datas ControlData[] -} - -enum PartType { - LED - FIBER -} - -model Part { - id Int @id @default(autoincrement()) - model_id Int - name String - type PartType - length Int? - - // relation => not in db - model Model @relation(fields: [model_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - - control_datas ControlData[] - led_effect LEDEffect[] - - @@unique([name, model_id]) -} - -model PositionData { - // id Int @id @default(autoincrement()) - dancer_id Int - frame_id Int - x Float - y Float - z Float - rx Float @default(0) - ry Float @default(0) - rz Float @default(0) - - // relation => not in db - dancer Dancer @relation(fields: [dancer_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - frame PositionFrame @relation(fields: [frame_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - - @@id([dancer_id, frame_id]) -} - -model PositionFrame { - id Int @id @default(autoincrement()) - start Int @unique - meta_rev Int @default(0) - data_rev Int @default(0) - - // relation => not in db - editing EditingPositionFrame? - position_datas PositionData[] -} - - -model LEDBulb { - id Int @id @default(autoincrement()) - control_id Int - position Int - color_id Int - alpha Int - // relation => not in db - control_datas ControlData @relation(fields: [control_id], references: [id], onDelete: Cascade, onUpdate: Cascade) -} - - - -enum ControlDataType { - COLOR - EFFECT - LED_BULBS -} - -model ControlData { - id Int @id @default(autoincrement()) - dancer_id Int - part_id Int - frame_id Int - type ControlDataType - color_id Int? - effect_id Int? - alpha Int - - // TODO: Check if one of color_id or effect_id is not null - - // relation => not in db - part Part @relation(fields: [part_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - frame ControlFrame @relation(fields: [frame_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - dancer Dancer @relation(fields: [dancer_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - - color Color? @relation(fields: [color_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - effect LEDEffect? @relation(fields: [effect_id], references: [id], onDelete: Cascade, onUpdate: Cascade) - led_bulbs LEDBulb[] - - @@unique([dancer_id, part_id, frame_id]) -} - -model ControlFrame { - id Int @id @default(autoincrement()) - start Int @unique - fade Boolean - meta_rev Int @default(0) - data_rev Int @default(0) - - // relation => not in db - editing EditingControlFrame? - control_datas ControlData[] -} - -model EffectListData { - id Int @id @default(autoincrement()) - start Int - end Int - description String? - // dancer_data Json[] - // controlFrames Json[] - // positionFrames Json[] -} - -model Logger { - id Int @id @default(autoincrement()) - user Int - variable_value Json? - field_name String - time DateTime @default(now()) - status String - error_message Json? - result Json? -} - -model Revision { - id Int @id @default(autoincrement()) - uuid String @unique - time DateTime @default(now()) -} diff --git a/editor-server/prisma/src/main.rs b/editor-server/prisma/src/main.rs deleted file mode 100644 index 74bd64124..000000000 --- a/editor-server/prisma/src/main.rs +++ /dev/null @@ -1,22 +0,0 @@ -use std::env::{args, var}; -use std::time; - -fn main() { - let args: Vec = args().collect(); - - // Check MySQL connection when migrating - if args.len() >= 2 && args[1] == "migrate" { - dotenv::dotenv().ok(); - - let mysql_host = var("DATABASE_URL").expect("DATABASE_URL is not set"); - println!("MySQL Host: {}", mysql_host); - - while let Err(_) = mysql::Conn::new(mysql_host.as_str()) { - println!("Waiting for mysql to start..."); - std::thread::sleep(time::Duration::from_secs(1)); - } - println!("MySQL is up and running!"); - } - - prisma_client_rust_cli::run(); -} diff --git a/editor-server/sea-orm/Cargo.toml b/editor-server/sea-orm/Cargo.toml new file mode 100644 index 000000000..d6a5eeeae --- /dev/null +++ b/editor-server/sea-orm/Cargo.toml @@ -0,0 +1,12 @@ +[package] +rust-version = "1.75.0" +name = "seaorm" +version = "0.1.0" +edition = "2021" + +[dependencies] +dotenv = "0.15.0" +mysql = "26.0.0" +sea-orm = { version = "1.1.4", features = [ "sqlx-mysql", "runtime-async-std-native-tls", "macros" ] } +tokio = { version = "1.43.0", features = ["full"] } +migration = { path = "./migration" } \ No newline at end of file diff --git a/editor-server/sea-orm/migration/Cargo.toml b/editor-server/sea-orm/migration/Cargo.toml new file mode 100644 index 000000000..02aeae2cb --- /dev/null +++ b/editor-server/sea-orm/migration/Cargo.toml @@ -0,0 +1,16 @@ +[package] +rust-version = "1.75.0" +name = "migration" +version = "0.1.0" +edition = "2021" + +[lib] +name = "migration" +path = "src/lib.rs" + +[dependencies] +tokio = { version = "1.43.0", features = ["full"] } + +[dependencies.sea-orm-migration] +version = "1.1.0" +features = [ "sqlx-mysql", "runtime-async-std-native-tls" ] \ No newline at end of file diff --git a/editor-server/sea-orm/migration/README.md b/editor-server/sea-orm/migration/README.md new file mode 100644 index 000000000..3b438d89e --- /dev/null +++ b/editor-server/sea-orm/migration/README.md @@ -0,0 +1,41 @@ +# Running Migrator CLI + +- Generate a new migration file + ```sh + cargo run -- generate MIGRATION_NAME + ``` +- Apply all pending migrations + ```sh + cargo run + ``` + ```sh + cargo run -- up + ``` +- Apply first 10 pending migrations + ```sh + cargo run -- up -n 10 + ``` +- Rollback last applied migrations + ```sh + cargo run -- down + ``` +- Rollback last 10 applied migrations + ```sh + cargo run -- down -n 10 + ``` +- Drop all tables from the database, then reapply all migrations + ```sh + cargo run -- fresh + ``` +- Rollback all applied migrations, then reapply all migrations + ```sh + cargo run -- refresh + ``` +- Rollback all applied migrations + ```sh + cargo run -- reset + ``` +- Check the status of all migrations + ```sh + cargo run -- status + ``` diff --git a/editor-server/sea-orm/migration/src/lib.rs b/editor-server/sea-orm/migration/src/lib.rs new file mode 100644 index 000000000..a68e7cfa0 --- /dev/null +++ b/editor-server/sea-orm/migration/src/lib.rs @@ -0,0 +1,12 @@ +pub use sea_orm_migration::prelude::*; + +mod m20260131_000001_create_table; + +pub struct Migrator; + +#[async_trait::async_trait] +impl MigratorTrait for Migrator { + fn migrations() -> Vec> { + vec![Box::new(m20260131_000001_create_table::Migration)] + } +} diff --git a/editor-server/sea-orm/migration/src/m20260131_000001_create_table.rs b/editor-server/sea-orm/migration/src/m20260131_000001_create_table.rs new file mode 100644 index 000000000..88bff01e2 --- /dev/null +++ b/editor-server/sea-orm/migration/src/m20260131_000001_create_table.rs @@ -0,0 +1,820 @@ +use sea_orm_migration::prelude::*; +use sea_query::{Alias, Expr}; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + let mut index_color_name = Index::create().unique().col(Color::Name).to_owned(); + manager + .create_table( + Table::create() + .table(Color::Table) + .if_not_exists() + .col( + ColumnDef::new(Color::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(Color::Name).string().not_null()) + .col(ColumnDef::new(Color::R).integer().not_null()) + .col(ColumnDef::new(Color::G).integer().not_null()) + .col(ColumnDef::new(Color::B).integer().not_null()) + .index(&mut index_color_name) + .to_owned(), + ) + .await?; + + let mut index_control_frame_start = + Index::create().unique().col(ControlFrame::Start).to_owned(); + manager + .create_table( + Table::create() + .table(ControlFrame::Table) + .if_not_exists() + .col( + ColumnDef::new(ControlFrame::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(ControlFrame::Start).integer().not_null()) + .col( + ColumnDef::new(ControlFrame::MetaRev) + .integer() + .not_null() + .default(0), + ) + .col( + ColumnDef::new(ControlFrame::DataRev) + .integer() + .not_null() + .default(0), + ) + .col( + ColumnDef::new(ControlFrame::FadeForNewStatus) + .boolean() + .not_null(), + ) + .index(&mut index_control_frame_start) + .to_owned(), + ) + .await?; + + let mut index_position_frame_start = Index::create() + .unique() + .col(PositionFrame::Start) + .to_owned(); + manager + .create_table( + Table::create() + .table(PositionFrame::Table) + .if_not_exists() + .col( + ColumnDef::new(PositionFrame::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(PositionFrame::Start).integer().not_null()) + .col( + ColumnDef::new(PositionFrame::MetaRev) + .integer() + .not_null() + .default(0), + ) + .col( + ColumnDef::new(PositionFrame::DataRev) + .integer() + .not_null() + .default(0), + ) + .index(&mut index_position_frame_start) + .to_owned(), + ) + .await?; + + let mut index_model_name = Index::create().unique().col(Model::Name).to_owned(); + manager + .create_table( + Table::create() + .table(Model::Table) + .if_not_exists() + .col( + ColumnDef::new(Model::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(Model::Name).string().not_null()) + .index(&mut index_model_name) + .to_owned(), + ) + .await?; + + let mut index_part_name_modelid = Index::create() + .unique() + .col(Part::Name) + .col(Part::ModelId) + .to_owned(); + manager + .create_table( + Table::create() + .table(Part::Table) + .if_not_exists() + .col( + ColumnDef::new(Part::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(Part::ModelId).integer().not_null()) + .col(ColumnDef::new(Part::Name).string().not_null()) + .col( + ColumnDef::new(Part::Type) + .custom(Alias::new("ENUM('LED','FIBER')")) + .not_null(), + ) + .col(ColumnDef::new(Part::Length).integer().null()) + .foreign_key( + ForeignKey::create() + .name("fk-part-model_id") + .from(Part::Table, Part::ModelId) + .to(Model::Table, Model::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .index(&mut index_part_name_modelid) + .to_owned(), + ) + .await?; + + let mut index_dancer_name = Index::create().unique().col(Dancer::Name).to_owned(); + manager + .create_table( + Table::create() + .table(Dancer::Table) + .if_not_exists() + .col( + ColumnDef::new(Dancer::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(Dancer::Name).string().not_null()) + .col(ColumnDef::new(Dancer::ModelId).integer().not_null()) + .foreign_key( + ForeignKey::create() + .name("fk-dancer-model_id") + .from(Dancer::Table, Dancer::ModelId) + .to(Model::Table, Model::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .index(&mut index_dancer_name) + .to_owned(), + ) + .await?; + + let mut index_led_effect = Index::create() + .unique() + .col(LEDEffect::Name) + .col(LEDEffect::ModelId) + .col(LEDEffect::PartId) + .to_owned(); + manager + .create_table( + Table::create() + .table(LEDEffect::Table) + .if_not_exists() + .col( + ColumnDef::new(LEDEffect::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(LEDEffect::Name).string().not_null()) + .col(ColumnDef::new(LEDEffect::ModelId).integer().not_null()) + .col(ColumnDef::new(LEDEffect::PartId).integer().not_null()) + .foreign_key( + ForeignKey::create() + .name("fk-led_effect-model_id") + .from(LEDEffect::Table, LEDEffect::ModelId) + .to(Model::Table, Model::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .foreign_key( + ForeignKey::create() + .name("fk-led_effect-part_id") + .from(LEDEffect::Table, LEDEffect::PartId) + .to(Part::Table, Part::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .index(&mut index_led_effect) + .to_owned(), + ) + .await?; + + let mut index_editing_control_frame = Index::create() + .unique() + .col(EditingControlFrame::FrameId) + .to_owned(); + manager + .create_table( + Table::create() + .table(EditingControlFrame::Table) + .if_not_exists() + .col( + ColumnDef::new(EditingControlFrame::UserId) + .integer() + .not_null() + .primary_key(), + ) + .col(ColumnDef::new(EditingControlFrame::FrameId).integer().null()) + .index(&mut index_editing_control_frame) + .foreign_key( + ForeignKey::create() + .name("fk-editing_control_frame-frame_id") + .from(EditingControlFrame::Table, EditingControlFrame::FrameId) + .to(ControlFrame::Table, ControlFrame::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .to_owned(), + ) + .await?; + + let mut index_editing_position_frame = Index::create() + .unique() + .col(EditingPositionFrame::FrameId) + .to_owned(); + manager + .create_table( + Table::create() + .table(EditingPositionFrame::Table) + .if_not_exists() + .col( + ColumnDef::new(EditingPositionFrame::UserId) + .integer() + .not_null() + .primary_key(), + ) + .col(ColumnDef::new(EditingPositionFrame::FrameId).integer().null()) + .index(&mut index_editing_position_frame) + .foreign_key( + ForeignKey::create() + .name("fk-editing_position_frame-frame_id") + .from(EditingPositionFrame::Table, EditingPositionFrame::FrameId) + .to(PositionFrame::Table, PositionFrame::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .to_owned(), + ) + .await?; + + let mut index_editing_led_effect = Index::create() + .unique() + .col(EditingLEDEffect::LedEffectId) + .to_owned(); + manager + .create_table( + Table::create() + .table(EditingLEDEffect::Table) + .if_not_exists() + .col( + ColumnDef::new(EditingLEDEffect::UserId) + .integer() + .not_null() + .primary_key(), + ) + .col(ColumnDef::new(EditingLEDEffect::LedEffectId).integer().null()) + .index(&mut index_editing_led_effect) + .foreign_key( + ForeignKey::create() + .name("fk-editing_led_effect-led_effect_id") + .from(EditingLEDEffect::Table, EditingLEDEffect::LedEffectId) + .to(LEDEffect::Table, LEDEffect::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .to_owned(), + ) + .await?; + + let mut pk_position_data = Index::create() + .col(PositionData::DancerId) + .col(PositionData::FrameId) + .to_owned(); + manager + .create_table( + Table::create() + .table(PositionData::Table) + .if_not_exists() + .col(ColumnDef::new(PositionData::DancerId).integer().not_null()) + .col(ColumnDef::new(PositionData::FrameId).integer().not_null()) + .col( + ColumnDef::new(PositionData::Type) + .custom(Alias::new("ENUM('POSITION','NO_EFFECT')")) + .not_null(), + ) + .col(ColumnDef::new(PositionData::X).double().null()) + .col(ColumnDef::new(PositionData::Y).double().null()) + .col(ColumnDef::new(PositionData::Z).double().null()) + .col( + ColumnDef::new(PositionData::Rx) + .double() + .not_null() + .default(Expr::cust("0")), + ) + .col( + ColumnDef::new(PositionData::Ry) + .double() + .not_null() + .default(Expr::cust("0")), + ) + .col( + ColumnDef::new(PositionData::Rz) + .double() + .not_null() + .default(Expr::cust("0")), + ) + .primary_key(&mut pk_position_data) + .foreign_key( + ForeignKey::create() + .name("fk-position_data-dancer_id") + .from(PositionData::Table, PositionData::DancerId) + .to(Dancer::Table, Dancer::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .foreign_key( + ForeignKey::create() + .name("fk-position_data-frame_id") + .from(PositionData::Table, PositionData::FrameId) + .to(PositionFrame::Table, PositionFrame::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .to_owned(), + ) + .await?; + + let mut index_control_data = Index::create() + .unique() + .col(ControlData::DancerId) + .col(ControlData::PartId) + .col(ControlData::FrameId) + .to_owned(); + manager + .create_table( + Table::create() + .table(ControlData::Table) + .if_not_exists() + .col( + ColumnDef::new(ControlData::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(ControlData::DancerId).integer().not_null()) + .col(ColumnDef::new(ControlData::PartId).integer().not_null()) + .col(ColumnDef::new(ControlData::FrameId).integer().not_null()) + .col( + ColumnDef::new(ControlData::Type) + .custom(Alias::new("ENUM('COLOR','EFFECT','LED_BULBS','NO_EFFECT')")) + .not_null(), + ) + .col(ColumnDef::new(ControlData::Fade).boolean().null()) + .col(ColumnDef::new(ControlData::ColorId).integer().null()) + .col(ColumnDef::new(ControlData::EffectId).integer().null()) + .col(ColumnDef::new(ControlData::Alpha).integer().null()) + .foreign_key( + ForeignKey::create() + .name("fk-control_data-dancer_id") + .from(ControlData::Table, ControlData::DancerId) + .to(Dancer::Table, Dancer::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .foreign_key( + ForeignKey::create() + .name("fk-control_data-part_id") + .from(ControlData::Table, ControlData::PartId) + .to(Part::Table, Part::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .foreign_key( + ForeignKey::create() + .name("fk-control_data-frame_id") + .from(ControlData::Table, ControlData::FrameId) + .to(ControlFrame::Table, ControlFrame::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .foreign_key( + ForeignKey::create() + .name("fk-control_data-color_id") + .from(ControlData::Table, ControlData::ColorId) + .to(Color::Table, Color::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .foreign_key( + ForeignKey::create() + .name("fk-control_data-effect_id") + .from(ControlData::Table, ControlData::EffectId) + .to(LEDEffect::Table, LEDEffect::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .index(&mut index_control_data) + .to_owned(), + ) + .await?; + + manager + .create_table( + Table::create() + .table(LEDBulb::Table) + .if_not_exists() + .col( + ColumnDef::new(LEDBulb::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(LEDBulb::ControlId).integer().not_null()) + .col(ColumnDef::new(LEDBulb::Position).integer().not_null()) + .col(ColumnDef::new(LEDBulb::ColorId).integer().not_null()) + .col(ColumnDef::new(LEDBulb::Alpha).integer().not_null()) + .foreign_key( + ForeignKey::create() + .name("fk-ledbulb-control_id") + .from(LEDBulb::Table, LEDBulb::ControlId) + .to(ControlData::Table, ControlData::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .to_owned(), + ) + .await?; + + let mut index_led_effect_state = Index::create() + .unique() + .col(LEDEffectState::EffectId) + .col(LEDEffectState::Position) + .to_owned(); + manager + .create_table( + Table::create() + .table(LEDEffectState::Table) + .if_not_exists() + .col( + ColumnDef::new(LEDEffectState::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(LEDEffectState::EffectId).integer().not_null()) + .col(ColumnDef::new(LEDEffectState::Position).integer().not_null()) + .col(ColumnDef::new(LEDEffectState::ColorId).integer().not_null()) + .col(ColumnDef::new(LEDEffectState::Alpha).integer().not_null()) + .foreign_key( + ForeignKey::create() + .name("fk-led_effect_state-effect_id") + .from(LEDEffectState::Table, LEDEffectState::EffectId) + .to(LEDEffect::Table, LEDEffect::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) + .index(&mut index_led_effect_state) + .to_owned(), + ) + .await?; + + manager + .create_table( + Table::create() + .table(EffectListData::Table) + .if_not_exists() + .col( + ColumnDef::new(EffectListData::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(EffectListData::Start).integer().not_null()) + .col(ColumnDef::new(EffectListData::End).integer().not_null()) + .col(ColumnDef::new(EffectListData::Description).string().null()) + .to_owned(), + ) + .await?; + + manager + .create_table( + Table::create() + .table(Logger::Table) + .if_not_exists() + .col( + ColumnDef::new(Logger::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(Logger::User).integer().not_null()) + .col(ColumnDef::new(Logger::VariableValue).json().null()) + .col(ColumnDef::new(Logger::FieldName).string().not_null()) + .col( + ColumnDef::new(Logger::Time) + .timestamp() + .not_null() + .default(Expr::cust("CURRENT_TIMESTAMP")), + ) + .col(ColumnDef::new(Logger::Status).string().not_null()) + .col(ColumnDef::new(Logger::ErrorMessage).json().null()) + .col(ColumnDef::new(Logger::Result).json().null()) + .to_owned(), + ) + .await?; + + let mut index_revision_uuid = Index::create().unique().col(Revision::Uuid).to_owned(); + manager + .create_table( + Table::create() + .table(Revision::Table) + .if_not_exists() + .col( + ColumnDef::new(Revision::Id) + .integer() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(Revision::Uuid).string().not_null()) + .col( + ColumnDef::new(Revision::Time) + .timestamp() + .not_null() + .default(Expr::cust("CURRENT_TIMESTAMP")), + ) + .index(&mut index_revision_uuid) + .to_owned(), + ) + .await?; + + Ok(()) + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .drop_table(Table::drop().table(Revision::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(Logger::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(EffectListData::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(LEDBulb::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(LEDEffectState::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(ControlData::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(PositionData::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(EditingLEDEffect::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(EditingPositionFrame::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(EditingControlFrame::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(LEDEffect::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(Dancer::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(Part::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(Model::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(PositionFrame::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(ControlFrame::Table).to_owned()) + .await?; + manager + .drop_table(Table::drop().table(Color::Table).to_owned()) + .await?; + Ok(()) + } +} + +#[derive(Iden)] +pub enum Color { + #[iden = "Color"] + Table, + Id, + Name, + R, + G, + B, +} + +#[derive(Iden)] +pub enum ControlFrame { + #[iden = "ControlFrame"] + Table, + Id, + Start, + MetaRev, + DataRev, + FadeForNewStatus, +} + +#[derive(Iden)] +pub enum PositionFrame { + #[iden = "PositionFrame"] + Table, + Id, + Start, + MetaRev, + DataRev, +} + +#[derive(Iden)] +pub enum Model { + #[iden = "Model"] + Table, + Id, + Name, +} + +#[derive(Iden)] +pub enum Part { + #[iden = "Part"] + Table, + Id, + ModelId, + Name, + Type, + Length, +} + +#[derive(Iden)] +pub enum Dancer { + #[iden = "Dancer"] + Table, + Id, + Name, + ModelId, +} + +#[derive(Iden)] +pub enum LEDEffect { + #[iden = "LEDEffect"] + Table, + Id, + Name, + ModelId, + PartId, +} + +#[derive(Iden)] +pub enum EditingControlFrame { + #[iden = "EditingControlFrame"] + Table, + UserId, + FrameId, +} + +#[derive(Iden)] +pub enum EditingPositionFrame { + #[iden = "EditingPositionFrame"] + Table, + UserId, + FrameId, +} + +#[derive(Iden)] +pub enum EditingLEDEffect { + #[iden = "EditingLEDEffect"] + Table, + UserId, + LedEffectId, +} + +#[derive(Iden)] +pub enum PositionData { + #[iden = "PositionData"] + Table, + DancerId, + FrameId, + Type, + X, + Y, + Z, + Rx, + Ry, + Rz, +} + +#[derive(Iden)] +pub enum ControlData { + #[iden = "ControlData"] + Table, + Id, + DancerId, + PartId, + FrameId, + Type, + Fade, + ColorId, + EffectId, + Alpha, +} + +#[derive(Iden)] +pub enum LEDBulb { + #[iden = "LEDBulb"] + Table, + Id, + ControlId, + Position, + ColorId, + Alpha, +} + +#[derive(Iden)] +pub enum LEDEffectState { + #[iden = "LEDEffectState"] + Table, + Id, + EffectId, + Position, + ColorId, + Alpha, +} + +#[derive(Iden)] +pub enum EffectListData { + #[iden = "EffectListData"] + Table, + Id, + Start, + End, + Description, +} + +#[derive(Iden)] +pub enum Logger { + #[iden = "Logger"] + Table, + Id, + User, + VariableValue, + FieldName, + Time, + Status, + ErrorMessage, + Result, +} + +#[derive(Iden)] +pub enum Revision { + #[iden = "Revision"] + Table, + Id, + Uuid, + Time, +} diff --git a/editor-server/sea-orm/migration/src/main.rs b/editor-server/sea-orm/migration/src/main.rs new file mode 100644 index 000000000..f054deaf8 --- /dev/null +++ b/editor-server/sea-orm/migration/src/main.rs @@ -0,0 +1,6 @@ +use sea_orm_migration::prelude::*; + +#[tokio::main] +async fn main() { + cli::run_cli(migration::Migrator).await; +} diff --git a/editor-server/sea-orm/src/entity/color.rs b/editor-server/sea-orm/src/entity/color.rs new file mode 100644 index 000000000..9af899002 --- /dev/null +++ b/editor-server/sea-orm/src/entity/color.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Color")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub name: String, + pub r: i32, + pub g: i32, + pub b: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::control_data::Entity")] + ControlData, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/control_data.rs b/editor-server/sea-orm/src/entity/control_data.rs new file mode 100644 index 000000000..222d0ac89 --- /dev/null +++ b/editor-server/sea-orm/src/entity/control_data.rs @@ -0,0 +1,106 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use super::sea_orm_active_enums::Type; +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "ControlData")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique_key = "dancer_id")] + pub dancer_id: i32, + #[sea_orm(unique_key = "dancer_id")] + pub part_id: i32, + #[sea_orm(unique_key = "dancer_id")] + pub frame_id: i32, + pub r#type: Type, + pub fade: Option, + pub color_id: Option, + pub effect_id: Option, + pub alpha: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::color::Entity", + from = "Column::ColorId", + to = "super::color::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Color, + #[sea_orm( + belongs_to = "super::control_frame::Entity", + from = "Column::FrameId", + to = "super::control_frame::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + ControlFrame, + #[sea_orm( + belongs_to = "super::dancer::Entity", + from = "Column::DancerId", + to = "super::dancer::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Dancer, + #[sea_orm(has_many = "super::led_bulb::Entity")] + LedBulb, + #[sea_orm( + belongs_to = "super::led_effect::Entity", + from = "Column::EffectId", + to = "super::led_effect::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + LedEffect, + #[sea_orm( + belongs_to = "super::part::Entity", + from = "Column::PartId", + to = "super::part::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Part, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Color.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlFrame.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Dancer.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedBulb.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffect.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Part.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/control_frame.rs b/editor-server/sea-orm/src/entity/control_frame.rs new file mode 100644 index 000000000..654ead16c --- /dev/null +++ b/editor-server/sea-orm/src/entity/control_frame.rs @@ -0,0 +1,37 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "ControlFrame")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub start: i32, + pub meta_rev: i32, + pub data_rev: i32, + pub fade_for_new_status: i8, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::control_data::Entity")] + ControlData, + #[sea_orm(has_one = "super::editing_control_frame::Entity")] + EditingControlFrame, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::EditingControlFrame.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/dancer.rs b/editor-server/sea-orm/src/entity/dancer.rs new file mode 100644 index 000000000..461a79922 --- /dev/null +++ b/editor-server/sea-orm/src/entity/dancer.rs @@ -0,0 +1,58 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Dancer")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub name: String, + pub model_id: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::control_data::Entity")] + ControlData, + #[sea_orm( + belongs_to = "super::model::Entity", + from = "Column::ModelId", + to = "super::model::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Model, + #[sea_orm(has_many = "super::position_data::Entity")] + PositionData, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Model.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PositionData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::position_data::Relation::PositionFrame.def() + } + fn via() -> Option { + Some(super::position_data::Relation::Dancer.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/editing_control_frame.rs b/editor-server/sea-orm/src/entity/editing_control_frame.rs new file mode 100644 index 000000000..dffbd48bd --- /dev/null +++ b/editor-server/sea-orm/src/entity/editing_control_frame.rs @@ -0,0 +1,32 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "EditingControlFrame")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub user_id: i32, + #[sea_orm(unique)] + pub frame_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::control_frame::Entity", + from = "Column::FrameId", + to = "super::control_frame::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + ControlFrame, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlFrame.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/editing_led_effect.rs b/editor-server/sea-orm/src/entity/editing_led_effect.rs new file mode 100644 index 000000000..dc404c5c8 --- /dev/null +++ b/editor-server/sea-orm/src/entity/editing_led_effect.rs @@ -0,0 +1,32 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "EditingLEDEffect")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub user_id: i32, + #[sea_orm(unique)] + pub led_effect_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::led_effect::Entity", + from = "Column::LedEffectId", + to = "super::led_effect::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + LedEffect, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffect.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/editing_position_frame.rs b/editor-server/sea-orm/src/entity/editing_position_frame.rs new file mode 100644 index 000000000..b8f66aa60 --- /dev/null +++ b/editor-server/sea-orm/src/entity/editing_position_frame.rs @@ -0,0 +1,32 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "EditingPositionFrame")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub user_id: i32, + #[sea_orm(unique)] + pub frame_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::position_frame::Entity", + from = "Column::FrameId", + to = "super::position_frame::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + PositionFrame, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PositionFrame.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/effect_list_data.rs b/editor-server/sea-orm/src/entity/effect_list_data.rs new file mode 100644 index 000000000..cdaa8645a --- /dev/null +++ b/editor-server/sea-orm/src/entity/effect_list_data.rs @@ -0,0 +1,18 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "EffectListData")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub start: i32, + pub end: i32, + pub description: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/led_bulb.rs b/editor-server/sea-orm/src/entity/led_bulb.rs new file mode 100644 index 000000000..e2dee7609 --- /dev/null +++ b/editor-server/sea-orm/src/entity/led_bulb.rs @@ -0,0 +1,34 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "LEDBulb")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub control_id: i32, + pub position: i32, + pub color_id: i32, + pub alpha: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::control_data::Entity", + from = "Column::ControlId", + to = "super::control_data::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + ControlData, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/led_effect.rs b/editor-server/sea-orm/src/entity/led_effect.rs new file mode 100644 index 000000000..e888dbd90 --- /dev/null +++ b/editor-server/sea-orm/src/entity/led_effect.rs @@ -0,0 +1,74 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "LEDEffect")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique_key = "name")] + pub name: String, + #[sea_orm(unique_key = "name")] + pub model_id: i32, + #[sea_orm(unique_key = "name")] + pub part_id: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::control_data::Entity")] + ControlData, + #[sea_orm(has_one = "super::editing_led_effect::Entity")] + EditingLedEffect, + #[sea_orm(has_many = "super::led_effect_state::Entity")] + LedEffectState, + #[sea_orm( + belongs_to = "super::model::Entity", + from = "Column::ModelId", + to = "super::model::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Model, + #[sea_orm( + belongs_to = "super::part::Entity", + from = "Column::PartId", + to = "super::part::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Part, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::EditingLedEffect.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffectState.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Model.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Part.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/led_effect_state.rs b/editor-server/sea-orm/src/entity/led_effect_state.rs new file mode 100644 index 000000000..4e884371b --- /dev/null +++ b/editor-server/sea-orm/src/entity/led_effect_state.rs @@ -0,0 +1,36 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "LEDEffectState")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique_key = "effect_id")] + pub effect_id: i32, + #[sea_orm(unique_key = "effect_id")] + pub position: i32, + pub color_id: i32, + pub alpha: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::led_effect::Entity", + from = "Column::EffectId", + to = "super::led_effect::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + LedEffect, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffect.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/logger.rs b/editor-server/sea-orm/src/entity/logger.rs new file mode 100644 index 000000000..6d7b3ecdd --- /dev/null +++ b/editor-server/sea-orm/src/entity/logger.rs @@ -0,0 +1,22 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Logger")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub user: i32, + pub variable_value: Option, + pub field_name: String, + pub time: DateTimeUtc, + pub status: String, + pub error_message: Option, + pub result: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/mod.rs b/editor-server/sea-orm/src/entity/mod.rs new file mode 100644 index 000000000..1350d07a2 --- /dev/null +++ b/editor-server/sea-orm/src/entity/mod.rs @@ -0,0 +1,22 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +pub mod prelude; + +pub mod color; +pub mod control_data; +pub mod control_frame; +pub mod dancer; +pub mod editing_control_frame; +pub mod editing_led_effect; +pub mod editing_position_frame; +pub mod effect_list_data; +pub mod led_bulb; +pub mod led_effect; +pub mod led_effect_state; +pub mod logger; +pub mod model; +pub mod part; +pub mod position_data; +pub mod position_frame; +pub mod revision; +pub mod sea_orm_active_enums; diff --git a/editor-server/sea-orm/src/entity/model.rs b/editor-server/sea-orm/src/entity/model.rs new file mode 100644 index 000000000..be53cef24 --- /dev/null +++ b/editor-server/sea-orm/src/entity/model.rs @@ -0,0 +1,42 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Model")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub name: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::dancer::Entity")] + Dancer, + #[sea_orm(has_many = "super::led_effect::Entity")] + LedEffect, + #[sea_orm(has_many = "super::part::Entity")] + Part, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Dancer.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffect.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Part.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/part.rs b/editor-server/sea-orm/src/entity/part.rs new file mode 100644 index 000000000..fc581b7d2 --- /dev/null +++ b/editor-server/sea-orm/src/entity/part.rs @@ -0,0 +1,53 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use super::sea_orm_active_enums::Type; +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Part")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique_key = "name")] + pub model_id: i32, + #[sea_orm(unique_key = "name")] + pub name: String, + pub r#type: Type, + pub length: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::control_data::Entity")] + ControlData, + #[sea_orm(has_many = "super::led_effect::Entity")] + LedEffect, + #[sea_orm( + belongs_to = "super::model::Entity", + from = "Column::ModelId", + to = "super::model::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Model, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffect.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Model.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/position_data.rs b/editor-server/sea-orm/src/entity/position_data.rs new file mode 100644 index 000000000..5fe92bb26 --- /dev/null +++ b/editor-server/sea-orm/src/entity/position_data.rs @@ -0,0 +1,60 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use super::sea_orm_active_enums::Type; +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "PositionData")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub dancer_id: i32, + #[sea_orm(primary_key, auto_increment = false)] + pub frame_id: i32, + pub r#type: Type, + #[sea_orm(column_type = "Double", nullable)] + pub x: Option, + #[sea_orm(column_type = "Double", nullable)] + pub y: Option, + #[sea_orm(column_type = "Double", nullable)] + pub z: Option, + #[sea_orm(column_type = "Double")] + pub rx: f64, + #[sea_orm(column_type = "Double")] + pub ry: f64, + #[sea_orm(column_type = "Double")] + pub rz: f64, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::dancer::Entity", + from = "Column::DancerId", + to = "super::dancer::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Dancer, + #[sea_orm( + belongs_to = "super::position_frame::Entity", + from = "Column::FrameId", + to = "super::position_frame::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + PositionFrame, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Dancer.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PositionFrame.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/position_frame.rs b/editor-server/sea-orm/src/entity/position_frame.rs new file mode 100644 index 000000000..3af699c36 --- /dev/null +++ b/editor-server/sea-orm/src/entity/position_frame.rs @@ -0,0 +1,45 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "PositionFrame")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub start: i32, + pub meta_rev: i32, + pub data_rev: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_one = "super::editing_position_frame::Entity")] + EditingPositionFrame, + #[sea_orm(has_many = "super::position_data::Entity")] + PositionData, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::EditingPositionFrame.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PositionData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::position_data::Relation::Dancer.def() + } + fn via() -> Option { + Some(super::position_data::Relation::PositionFrame.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/prelude.rs b/editor-server/sea-orm/src/entity/prelude.rs new file mode 100644 index 000000000..de16880d1 --- /dev/null +++ b/editor-server/sea-orm/src/entity/prelude.rs @@ -0,0 +1,19 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +pub use super::color::Entity as Color; +pub use super::control_data::Entity as ControlData; +pub use super::control_frame::Entity as ControlFrame; +pub use super::dancer::Entity as Dancer; +pub use super::editing_control_frame::Entity as EditingControlFrame; +pub use super::editing_led_effect::Entity as EditingLedEffect; +pub use super::editing_position_frame::Entity as EditingPositionFrame; +pub use super::effect_list_data::Entity as EffectListData; +pub use super::led_bulb::Entity as LedBulb; +pub use super::led_effect::Entity as LedEffect; +pub use super::led_effect_state::Entity as LedEffectState; +pub use super::logger::Entity as Logger; +pub use super::model::Entity as Model; +pub use super::part::Entity as Part; +pub use super::position_data::Entity as PositionData; +pub use super::position_frame::Entity as PositionFrame; +pub use super::revision::Entity as Revision; diff --git a/editor-server/sea-orm/src/entity/revision.rs b/editor-server/sea-orm/src/entity/revision.rs new file mode 100644 index 000000000..864dad777 --- /dev/null +++ b/editor-server/sea-orm/src/entity/revision.rs @@ -0,0 +1,18 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Revision")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub uuid: String, + pub time: DateTimeUtc, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/editor-server/sea-orm/src/entity/sea_orm_active_enums.rs b/editor-server/sea-orm/src/entity/sea_orm_active_enums.rs new file mode 100644 index 000000000..b32873efe --- /dev/null +++ b/editor-server/sea-orm/src/entity/sea_orm_active_enums.rs @@ -0,0 +1,12 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "type")] +pub enum Type { + #[sea_orm(string_value = "POSITION")] + Position, + #[sea_orm(string_value = "NO_EFFECT")] + NoEffect, +} diff --git a/editor-server/sea-orm/src/main.rs b/editor-server/sea-orm/src/main.rs new file mode 100644 index 000000000..6ab94fefa --- /dev/null +++ b/editor-server/sea-orm/src/main.rs @@ -0,0 +1,40 @@ +use migration::{Migrator, MigratorTrait}; +use sea_orm::Database; +use std::env::{args, var}; +use std::time; + +#[tokio::main] +async fn main() { + let args: Vec = args().collect(); + + // Check MySQL connection when migrating + if args.len() >= 2 && args[1] == "migrate" { + dotenv::dotenv().ok(); + + let mysql_host = var("DATABASE_URL").expect("DATABASE_URL is not set"); + println!("MySQL Host: {}", mysql_host); + + loop { + let connection = match Database::connect(mysql_host.as_str()).await { + Ok(conn) => conn, + Err(_) => { + println!("Waiting for mysql to start..."); + tokio::time::sleep(time::Duration::from_secs(1)).await; + continue; + } + }; + + match Migrator::up(&connection, None).await { + Ok(_) => { + println!("Migration completed!"); + break; + } + Err(e) => { + println!("Migration failed: {:?}. Retrying in 1 second...", e); + tokio::time::sleep(time::Duration::from_secs(1)).await; + continue; + } + } + } + } +} \ No newline at end of file diff --git a/editor-server/src/db/clients.rs b/editor-server/src/db/clients.rs index 30f4b8676..d6f35c990 100644 --- a/editor-server/src/db/clients.rs +++ b/editor-server/src/db/clients.rs @@ -10,7 +10,7 @@ pub struct AppClients { } impl AppClients { - pub async fn connect(mysql: &'static str, redis: (&'static str, &'static str)) -> Self { + pub async fn connect(mysql: &str, redis: (&str, &str)) -> Self { Self { mysql_pool: build_mysql_pool(mysql).await, redis_client: build_redis_client(redis.0, redis.1).await, @@ -26,7 +26,7 @@ impl AppClients { } } -pub async fn build_mysql_pool(host: &'static str) -> Pool { +pub async fn build_mysql_pool(host: &str) -> Pool { PoolOptions::new() .max_connections(20) .connect(host) @@ -34,6 +34,6 @@ pub async fn build_mysql_pool(host: &'static str) -> Pool { .expect("Failed to create mysql pool") } -pub async fn build_redis_client(host: &'static str, port: &'static str) -> Client { +pub async fn build_redis_client(host: &str, port: &str) -> Client { Client::open(format!("redis://{host}:{port}")).expect("Failed to create redis client") } diff --git a/editor-server/src/db/types/control_data.rs b/editor-server/src/db/types/control_data.rs index f2488025d..b6444e351 100644 --- a/editor-server/src/db/types/control_data.rs +++ b/editor-server/src/db/types/control_data.rs @@ -5,6 +5,8 @@ use sqlx::Decode; #[derive(Debug, Clone, PartialEq, Decode)] pub enum ControlType { + #[sqlx(rename = "NO_EFFECT")] + NoEffect, #[sqlx(rename = "COLOR")] Color, #[sqlx(rename = "EFFECT")] @@ -27,6 +29,7 @@ impl From for ControlType { impl From for String { fn from(val: ControlType) -> Self { match val { + ControlType::NoEffect => "NO_EFFECT".to_string(), ControlType::Effect => "EFFECT".to_string(), ControlType::Color => "COLOR".to_string(), ControlType::LEDBulbs => "LED_BULBS".to_string(), diff --git a/editor-server/src/db/types/position.rs b/editor-server/src/db/types/position.rs index 004e81385..3e5790e2a 100644 --- a/editor-server/src/db/types/position.rs +++ b/editor-server/src/db/types/position.rs @@ -4,7 +4,7 @@ use async_graphql::SimpleObject; use serde::{Deserialize, Serialize}; #[derive(SimpleObject, Serialize, Deserialize, Default, Debug, Clone)] -// ref: prisma/schema.prisma PositionData type +// ref: sea-orm/migration/src/m20260131_000001_create_table.rs PositionData type pub struct PositionData { pub dancer_id: i32, pub frame_id: i32, diff --git a/editor-server/src/global/envs.rs b/editor-server/src/global/envs.rs index f2808a7be..9339f258d 100644 --- a/editor-server/src/global/envs.rs +++ b/editor-server/src/global/envs.rs @@ -17,7 +17,7 @@ pub fn set() { return; } - let env = var("ENV").expect("ENV not set"); + let env = var("ENV").unwrap_or_else(|_| "dev".to_string()); let redis_ctrl_prefix = var("REDIS_CTRL_PREFIX").unwrap_or_else(|_| "CTRLFRAME_".to_string()); let redis_pos_prefix = var("REDIS_POS_PREFIX").unwrap_or_else(|_| "POSFRAME_".to_string()); diff --git a/editor-server/src/graphql/mutations/control_frame.rs b/editor-server/src/graphql/mutations/control_frame.rs index 247596bf6..a2725bb2e 100644 --- a/editor-server/src/graphql/mutations/control_frame.rs +++ b/editor-server/src/graphql/mutations/control_frame.rs @@ -58,6 +58,7 @@ impl ControlFrameMutation { start: i32, fade: bool, control_data: Vec>>, + // [dancer][part][type, id, alpha, fade] led_control_data: Vec>>>, ) -> FieldResult { let context = ctx.data::()?; @@ -117,7 +118,7 @@ impl ControlFrameMutation { // the control data should be a 3d array // representing all the data on every parts of every dancers // the first dimension is the dancer id, the second dimension is the part id, and the third dimension is the data - // the data is a 1d array of length 2, first element representing the Color id or LEDEffect id, the second element representing the alpha value + // the data is a 1d array of length 4 if control_data.is_empty() || led_control_data.is_empty() { let error_message = "Control data is empty.".to_string(); @@ -162,6 +163,11 @@ impl ControlFrameMutation { let mut errors: Vec = Vec::new(); + const NO_EFFECT: i32 = 0; + const COLOR: i32 = 1; + const EFFECT: i32 = 2; + const LED_BULBS: i32 = 3; + // please check the syntax of for loop in rust // the iter() method will return an iterator of the array // the enumerate() method will return a tuple of (index, value) @@ -173,16 +179,18 @@ impl ControlFrameMutation { if data.len() != dancer.len() || dancer_bulb_datas.len() != dancer.len() { if dancer.len() < data.len() || dancer.len() < dancer_bulb_datas.len() { errors.push(format!( - "Control data in dancer {index} is more than parts in payload." + "Control data in dancer {} is more than parts in payload.", + index + 1 )); // if the data is more than the parts, when iter through parts will have "out of bound" error // so we need to skip the rest of the iteration - break; + continue; } else { errors.push(format!( - "Control data in dancer {index} is less than parts in payload." + "Control data in dancer {} is less than parts in payload.", + index + 1 )); - break; + continue; } } @@ -202,19 +210,28 @@ impl ControlFrameMutation { // )); // break; // } - - // if part_data is not an array, return error if part_data.is_empty() && part_bulb_datas.is_empty() { errors.push(format!( - "There are neither effect/color data or LED bulb data in dancer {} part {}.", - index + 1, part_index + 1 - )); - break; + "There are neither effect/color data or LED bulb data in dancer {} part {}.", + index + 1, + part_index + 1 + )); + continue; + } + + + if !part_bulb_datas.is_empty() && part_data.is_empty() { + errors.push(format!( + "Bulb data provided but part_data is empty for dancer #{} part #{} (expected [type,id,alpha,fade])", + index + 1, + part_index + 1 + )); + continue; } // check if the led_control_data is an array of length 2 for bulb_data in part_bulb_datas.iter() { - if bulb_data.len() != 2 && !part_data.is_empty() { + if bulb_data.len() != 2 { let error_message = format!( "LED Bulb data of dancer #{} part #{} is not an array of length 2", index + 1, @@ -224,73 +241,136 @@ impl ControlFrameMutation { } } - // if part_data is an array, check if the length of the array is 2 - if part_data.len() != 2 && !part_data.is_empty() { - let error_message = format!( - "Data of dancer #{index} part #{part_index} is not an array of length 2" - ); - errors.push(error_message); - } + // if part_data is an array, check if the length of the array is 4 + if !part_data.is_empty() { + if part_data.len() != 4 { + errors.push(format!( + "Control data of dancer #{} part #{} is not an array of length 4 (expected: [type, id, alpha, fade])", + index + 1, part_index + 1 + )); + continue; + } + let control_type = part_data[0]; + let id_value = part_data[1]; + let alpha = part_data[2]; + let fade_value = part_data[3]; + + // check if control_type is valid + if control_type < 0 || control_type > 3 { + errors.push(format!( + "Invalid type value {} for dancer #{} part #{} (must be 0-3: NO_EFFECT=0, COLOR=1, EFFECT=2, LED_BULBS=3)", + control_type, index + 1, part_index + 1 + )); + continue; + } - match part_type { - // if the part is Fiber, check if the color is valid - PartType::FIBER => { - let color_id = part_data[0]; - - // check if the color is valid - if !all_color_ids.contains(&color_id) { - let error_message = format!( - "Color of dancer #{index} part #{part_index} is not a valid color" - ); - errors.push(error_message); - } + // check if fade_value is valid + if fade_value != 0 && fade_value != 1 { + errors.push(format!( + "Fade value of dancer #{} part #{} must be 0 or 1", + index + 1, part_index + 1 + )); + } + // For non-NO_EFFECT types, validate alpha + if control_type != NO_EFFECT && (alpha < 0 || alpha > 255) { + errors.push(format!( + "Alpha value of dancer #{} part #{} must be between 0 and 255", + index + 1, part_index + 1 + )); } - // if the part is LED, check if the effect is valid - PartType::LED => { - if is_data_led_bulb { - if part_bulb_datas.len() != part.length.unwrap() as usize { - let error_message = format!( - "LED Bulb data of dancer #{} part #{} is not an array of length {}", - index + 1, part_index + 1, part.length.unwrap() - ); - errors.push(error_message); - } - for bulb_data in part_bulb_datas.iter() { - let color_id = bulb_data[0]; + match part_type { + PartType::FIBER => { + // only COLOR or NO_EFFECT is valid for Fiber + match control_type { + NO_EFFECT => {} + COLOR => { + if !all_color_ids.contains(&id_value) { + errors.push(format!( + "Color ID {} of dancer #{} part #{} is not a valid color", + id_value, index + 1, part_index + 1 + )); + } + } + _ => { + errors.push(format!( + "Invalid type {} for FIBER part in dancer #{} part #{} (FIBER only supports NO_EFFECT=0 or COLOR=1)", + control_type, index + 1, part_index + 1 + )); + } + } + } + PartType::LED => { + if is_data_led_bulb { + if control_type != LED_BULBS { + errors.push(format!( + "Type mismatch for dancer #{} part #{}: LED bulb data provided but type is {} (expected LED_BULBS=3)", + index + 1, part_index + 1, control_type + )); + } + + // validate bulb count + if part_bulb_datas.len() != part.length.unwrap() as usize { + errors.push(format!( + "LED Bulb data of dancer #{} part #{} has {} bulbs but part length is {}", + index + 1, part_index + 1, part_bulb_datas.len(), part.length.unwrap() + )); + } - // check if the color is valid - if !all_color_ids.contains(&color_id) - && color_id != 0 - && color_id != -1 - { - let error_message = format!( - "Color of LED Bulb of dancer #{} part #{} is not a valid color", + for (bulb_index, bulb_data) in part_bulb_datas.iter().enumerate() { + let color_id = bulb_data[0]; + let bulb_alpha = bulb_data[1]; + + if !all_color_ids.contains(&color_id) && color_id != 0 && color_id != -1 { + errors.push(format!( + "Color {} of LED Bulb #{} in dancer #{} part #{} is not a valid color", + color_id, bulb_index + 1, index + 1, part_index + 1 + )); + } + if bulb_alpha < 0 || bulb_alpha > 255 { + errors.push(format!( + "Alpha {} of LED Bulb #{} in dancer #{} part #{} must be between 0 and 255", + bulb_alpha, bulb_index + 1, index + 1, part_index + 1 + )); + } + } + } else { + // only EFFECT or NO_EFFECT is valid for LED + match control_type { + NO_EFFECT => {} + EFFECT => { + if !all_led_effect_ids.contains(&id_value) { + errors.push(format!( + "Effect ID {} of dancer #{} part #{} is not a valid effect", + id_value, index + 1, part_index + 1 + )); + } + } + LED_BULBS => { + errors.push(format!( + "Type is LED_BULBS but no bulb data provided for dancer #{} part #{}", + index + 1, part_index + 1 + )); + } + COLOR => { + errors.push(format!( + "Invalid type COLOR for LED part in dancer #{} part #{} (LED only supports NO_EFFECT, EFFECT, or LED_BULBS)", index + 1, part_index + 1 - ); - errors.push(error_message); + )); + } + _ => { + errors.push(format!( + "Invalid type {} for LED part in dancer #{} part #{}", + control_type, index + 1, part_index + 1 + )); + } } } - } else { - let effect_id = part_data[0]; - - // check if the effect is valid - if !all_led_effect_ids.contains(&effect_id) - && effect_id != 0 - && effect_id != -1 - { - let error_message = format!( - "Effect of dancer #{} part #{} is not a valid effect", - index + 1, - part_index + 1 - ); - errors.push(error_message); - } - } - } - }; + } + }; + } } - } + } if !errors.is_empty() { // turn errors from Vec into a string @@ -303,7 +383,7 @@ impl ControlFrameMutation { // create a new control frame and insert it into the database let new_control_frame = sqlx::query!( r#" - INSERT INTO ControlFrame (start, fade) + INSERT INTO ControlFrame (start, fade_for_new_status) VALUES (?, ?); "#, start, @@ -322,91 +402,119 @@ impl ControlFrameMutation { let dancer = &dancers[index]; let dancer_bulb_datas = &led_control_data[index]; + + // iterate through every part of the dancer for (part_index, part_data) in data.iter().enumerate() { let dancer_id = &dancer[part_index].dancer_id; let part = &dancer[part_index]; - let part_type = &part.part_type; - let part_bulb_datas = &dancer_bulb_datas[part_index]; - let is_data_led_bulb = !part_bulb_datas.is_empty(); - - match part_type { - PartType::FIBER => { - // create a new control data and insert it into the database - // please refer to the schema of ControlData table + if part_data.is_empty() { + return Err(Error::new(format!( + "part_data is empty during insertion for dancer #{} part #{}", + index + 1, + part_index + 1 + ))); + } + let control_type = part_data[0]; + let id_value = part_data[1]; + let alpha = part_data[2]; + let fade_bool = part_data[3] == 1; + match control_type { + NO_EFFECT => { + // store all null for fade, color_id, effect_id, alpha + sqlx::query!( + r#" + INSERT INTO ControlData + (dancer_id, part_id, frame_id, type, fade, color_id, effect_id, alpha) + VALUES (?, ?, ?, ?, NULL, NULL, NULL, NULL); + "#, + dancer_id, + part.part_id, + new_control_frame_id, + "NO_EFFECT", + ) + .execute(&mut *tx) + .await?; + } + COLOR => { sqlx::query!( r#" INSERT INTO ControlData - (dancer_id, part_id, frame_id, type, color_id, alpha) - VALUES (?, ?, ?, ?, ?, ?); + (dancer_id, part_id, frame_id, type, color_id, fade, alpha) + VALUES (?, ?, ?, ?, ?, ?, ?); "#, dancer_id, part.part_id, new_control_frame_id, "COLOR", - part_data[0], - part_data[1], + id_value, + fade_bool, + alpha, ) .execute(&mut *tx) .await?; } - PartType::LED => { - let effect_id = part_data[0]; - let alpha = part_data[1]; + EFFECT => { + sqlx::query!( + r#" + INSERT INTO ControlData + (dancer_id, part_id, frame_id, type, effect_id, fade, alpha) + VALUES (?, ?, ?, ?, ?, ?, ?); + "#, + dancer_id, + part.part_id, + new_control_frame_id, + "EFFECT", + id_value, + fade_bool, + alpha, + ) + .execute(&mut *tx) + .await?; + } + LED_BULBS => { + let new_control_data = sqlx::query!( + r#" + INSERT INTO ControlData + (dancer_id, part_id, frame_id, type, fade, alpha) + VALUES (?, ?, ?, ?, ?, ?); + "#, + dancer_id, + part.part_id, + new_control_frame_id, + "LED_BULBS", + fade_bool, + alpha, + ) + .execute(&mut *tx) + .await?; - // create a new control data and insert it into the database - if is_data_led_bulb { - let new_control_data = sqlx::query!( - r#" - INSERT INTO ControlData - (dancer_id, part_id, frame_id, type, alpha) - VALUES (?, ?, ?, ?, ?); - "#, - dancer_id, - part.part_id, - new_control_frame_id, - "LED_BULBS", - alpha - ) - .execute(&mut *tx) - .await?; + let control_id = new_control_data.last_insert_id() as i32; - let control_id = new_control_data.last_insert_id() as i32; - - for (position, bulb_data) in part_bulb_datas.iter().enumerate() { - sqlx::query!( - r#" - INSERT INTO LEDBulb - (control_id, color_id, alpha, position) - VALUES (?, ?, ?, ?); - "#, - control_id, - bulb_data[0], - bulb_data[1], - position as i32, - ) - .execute(&mut *tx) - .await?; - } - } else { + // Insert individual bulb data + for (position, bulb_data) in part_bulb_datas.iter().enumerate() { sqlx::query!( r#" - INSERT INTO ControlData - (dancer_id, part_id, frame_id, type, effect_id, alpha) - VALUES (?, ?, ?, ?, ?, ?); + INSERT INTO LEDBulb + (control_id, color_id, alpha, position) + VALUES(?, ?, ?, ?); "#, - dancer_id, - part.part_id, - new_control_frame_id, - "EFFECT", - effect_id, - alpha, + control_id, + bulb_data[0], + bulb_data[1], + position as i32, ) .execute(&mut *tx) .await?; } } + _ => { + return Err(Error::new(format!( + "Invalid control type {} encountered during insertion", + control_type + ))); + } } } } @@ -499,6 +607,8 @@ impl ControlFrameMutation { tracing::info!("Mutation: editControlFrame"); + let mut tx = mysql.begin().await?; + // get the input data let frame_id = input.frame_id; if frame_id < 0 { @@ -507,8 +617,7 @@ impl ControlFrameMutation { // if the start time is given, check if the new time is already been occupied by another frame // also check if the new time is valid - if input.start.is_some() { - let start = input.start.unwrap(); + if let Some(start) = input.start { // check if the new time is already been occupied by another frame @@ -524,7 +633,7 @@ impl ControlFrameMutation { start, frame_id ) - .fetch_one(mysql) + .fetch_one(&mut *tx) .await? .exist; @@ -551,7 +660,7 @@ impl ControlFrameMutation { SELECT id, start, - fade as "fade: bool", + fade_for_new_status as "fade: bool", meta_rev, data_rev FROM ControlFrame @@ -559,7 +668,7 @@ impl ControlFrameMutation { "#, frame_id ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await; // if the original frame is not found, return error @@ -583,7 +692,7 @@ impl ControlFrameMutation { "#, frame_id, ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await?; if let Some(editing_control_frame) = is_editing { @@ -615,14 +724,14 @@ impl ControlFrameMutation { sqlx::query!( r#" UPDATE ControlFrame - SET start = ?, fade = ? + SET start = ?, fade_for_new_status = ? WHERE id = ?; "#, start, fade, frame_id ) - .execute(mysql) + .execute(&mut *tx) .await?; // update revision of the frame @@ -634,9 +743,11 @@ impl ControlFrameMutation { "#, frame_id ) - .execute(mysql) + .execute(&mut *tx) .await?; + tx.commit().await?; + // update redis control update_redis_control(mysql, &clients.redis_client, frame_id).await?; let redis_control = get_redis_control(&clients.redis_client, frame_id).await?; @@ -723,6 +834,8 @@ impl ControlFrameMutation { tracing::info!("Mutation: deleteControlFrame"); + let mut tx = mysql.begin().await?; + // get the input data let frame_id = input.frame_id; @@ -739,7 +852,7 @@ impl ControlFrameMutation { SELECT id, start, - fade as "fade: bool", + fade_for_new_status as "fade: bool", meta_rev, data_rev FROM ControlFrame @@ -747,7 +860,7 @@ impl ControlFrameMutation { "#, frame_id ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await; // if the original frame is not found, return error @@ -775,7 +888,7 @@ impl ControlFrameMutation { "#, frame_id, ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await?; if let Some(editing_control_frame) = is_editing { @@ -796,33 +909,10 @@ impl ControlFrameMutation { "#, frame_id ) - .execute(mysql) - .await?; - - // delete LED bulb data - sqlx::query!( - r#" - DELETE FROM LEDBulb - WHERE control_id IN ( - SELECT id FROM ControlData - WHERE frame_id = ? - ); - "#, - frame_id - ) - .execute(mysql) + .execute(&mut *tx) .await?; - // delete control data - sqlx::query!( - r#" - DELETE FROM ControlData - WHERE frame_id = ?; - "#, - frame_id - ) - .execute(mysql) - .await?; + tx.commit().await?; // update redis control update_redis_control(mysql, &clients.redis_client, frame_id).await?; diff --git a/editor-server/src/graphql/mutations/control_map.rs b/editor-server/src/graphql/mutations/control_map.rs index c247ce4f3..3a467e39d 100644 --- a/editor-server/src/graphql/mutations/control_map.rs +++ b/editor-server/src/graphql/mutations/control_map.rs @@ -79,11 +79,9 @@ impl ControlMapMutation { // get the input data let frame_id = input.frame_id; - let control_data = input.control_data; - let led_bulb_data = input.led_bulb_data; // check if the control_data is given - let control_data = match control_data { + let control_data = match input.control_data { Some(data) => data, None => { return Err(Error::new( @@ -92,7 +90,7 @@ impl ControlMapMutation { } }; - let led_bulb_data = match led_bulb_data { + let led_bulb_data = match input.led_bulb_data { Some(data) => data, None => { return Err(Error::new( @@ -106,6 +104,14 @@ impl ControlMapMutation { return Err(Error::new("Frame id is not valid")); } + // Type constants + const NO_EFFECT: i32 = 0; + const COLOR: i32 = 1; + const EFFECT: i32 = 2; + const LED_BULBS: i32 = 3; + + let mut tx = mysql.begin().await?; + // check if the frame exists let is_frame_exists = sqlx::query!( r#" @@ -115,7 +121,7 @@ impl ControlMapMutation { "#, frame_id, ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await?; // if the frame does not exist, return error @@ -134,16 +140,16 @@ impl ControlMapMutation { "#, frame_id, ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await?; if let Some(editing_control_frame) = is_editing { - let editing_user_id = editing_control_frame.user_id; // if the frame is being edited by others, return error - if editing_user_id != context.user_id { + if editing_control_frame.user_id != context.user_id { return Err(Error::new(format!( - "The target frame is being edited by user #{editing_user_id}" + "The target frame is being edited by user #{}", + editing_control_frame.user_id ))); } }; @@ -175,7 +181,7 @@ impl ControlMapMutation { "#, frame_id ) - .fetch_all(mysql) + .fetch_all(&mut *tx) .await?; // Use the partition_by_field function to group raw_dancer_data by dancer_id @@ -205,6 +211,22 @@ impl ControlMapMutation { return Err(Error::new(error_message)); } } + if led_bulb_data.len() != dancers.len() { + // to avoid subtract overflow when dancers.len() < led_bulb_data.len() + if dancers.len() < led_bulb_data.len() { + let error_message = format!( + "LED bulb data is more than dancers in payload. Extra number: {}", + led_bulb_data.len() - dancers.len() + ); + return Err(Error::new(error_message)); + } else { + let error_message = format!( + "LED bulb data is less than dancers in payload. Missing number: {}", + dancers.len() - led_bulb_data.len() + ); + return Err(Error::new(error_message)); + } + } // for the following check, we need to get the data of Color and LEDEffect first // fetch data about colors and LED effects @@ -213,7 +235,7 @@ impl ControlMapMutation { SELECT id FROM Color ORDER BY id ASC; "#, ) - .fetch_all(mysql) + .fetch_all(&mut *tx) .await? .iter() .map(|color_id| color_id.id) @@ -224,7 +246,7 @@ impl ControlMapMutation { SELECT id FROM LEDEffect ORDER BY id ASC; "#, ) - .fetch_all(mysql) + .fetch_all(&mut *tx) .await? .into_iter() .map(|effect_id| effect_id.id) @@ -241,14 +263,16 @@ impl ControlMapMutation { if data.len() != dancer.len() || led_bulb_data.len() != dancer.len() { if dancer.len() < data.len() || dancer.len() < led_bulb_data.len() { errors.push(format!( - "Control data in dancer {index} is more than parts in payload." + "Control data in dancer {} is more than parts in payload.", + index + 1 )); // if the data is more than the parts, when iter through parts will have "out of bound" error // so we need to skip the rest of the iteration break; } else { errors.push(format!( - "Control data in dancer {index} is less than parts in payload." + "Control data in dancer {} is less than parts in payload.", + index + 1 )); break; } @@ -274,101 +298,144 @@ impl ControlMapMutation { // fourth , check if the data of each part have proper format // if _data is not an array, return error - if part_data.is_empty() || part_data.len() < 2 { - let error_message = - format!("Data of dancer #{index} part #{part_index} is not an array"); - errors.push(error_message); + if part_data.is_empty() || part_data.len() != 4 { + errors.push(format!( + "Data of dancer #{} part #{} must be [type, id, alpha, fade] (len=4), got len={}", + index + 1, + part_index + 1, + part_data.len() + )); + continue; } - // check if the led_bulb_data is an array of length 2 - for bulb_data in led_bulb_data.iter() { - if bulb_data.len() != 2 { - let error_message = format!( - "LED Bulb data of dancer #{} part #{} is not an array of length 2", - index + 1, - part_index + 1 - ); - errors.push(error_message); - } - } + let control_type = part_data[0]; + let id_value = part_data[1]; + let alpha = part_data[2]; + let fade_value = part_data[3]; - // if _data is an array, check if the length of the array is 2 - if part_data.len() != 2 { - let error_message = format!( - "Data of dancer #{} part #{} is not an array of length 2", + if control_type < 0 || control_type > 3 { + errors.push(format!( + "Invalid type {} for dancer #{} part #{} (0..3 expected)", + control_type, index + 1, part_index + 1 - ); - errors.push(error_message.clone()); - break; + )); + continue; + } + + if control_type != NO_EFFECT { + if alpha < 0 || alpha > 255 { + errors.push(format!( + "Alpha out of range for dancer #{} part #{}: {} (0..255 expected)", + index + 1, + part_index + 1, + alpha + )); + } + if fade_value != 0 && fade_value != 1 { + errors.push(format!( + "Fade must be 0 or 1 for dancer #{} part #{}: {}", + index + 1, + part_index + 1, + fade_value + )); + } } match part_type { - // if the part is Fiber, check if the color is valid PartType::FIBER => { - let color_id = part_data[0]; - - // check if the color is valid - if !all_color_ids.contains(&color_id) { - let error_message = format!( - "Color of dancer #{} part #{} is not a valid color", - index + 1, - part_index + 1 - ); - errors.push(error_message); + match control_type { + NO_EFFECT => {} + COLOR => { + if !all_color_ids.contains(&id_value) { + errors.push(format!( + "Invalid color_id {} for dancer #{} part #{}", + id_value, + index + 1, + part_index + 1 + )); + } + } + _ => { + errors.push(format!( + "FIBER only supports NO_EFFECT(0) or COLOR(1). Got type = {} at dancer #{} part #{}", + control_type, + index + 1, + part_index + 1 + )); + } } } - // if the part is LED, check if the effect is valid PartType::LED => { - let effect_id = part_data[0]; - - if effect_id == 0 { - // LED bulbs - if led_bulb_data.len() != part.length.unwrap() as usize { - let error_message = format!( - "LED Bulb data of dancer #{} part #{} is not an array of length {}", - index + 1, part_index + 1, part.length.unwrap() - ); - errors.push(error_message); - } - - for bulb_data in led_bulb_data.iter() { - let color_id = bulb_data[0]; - - // check if the color is valid - if !all_color_ids.contains(&color_id) && color_id != -1 { - let error_message = format!( - "Color of LED Bulb of dancer #{} part #{} is not a valid color", - index + 1, part_index + 1 - ); - errors.push(error_message); + match control_type { + NO_EFFECT => {} + EFFECT => { + if !all_led_effect_ids.contains(&id_value) { + errors.push(format!( + "Invalid effect_id {} for dancer #{} part #{}", + id_value, + index + 1, + part_index + 1 + )); } } - } else { - // LED effect - if effect_id > 0 && !all_led_effect_ids.contains(&effect_id) { - let error_message = format!( - "Effect of dancer #{} part #{} is not a valid effect", - index + 1, - part_index + 1 - ); - errors.push(error_message); + LED_BULBS => { + let expected_len = match part.length { + Some(len) if len >= 0 => len as usize, + _ => { + errors.push(format!( + "LED part length is NULL/invalid for dancer #{} part #{}", + index + 1, + part_index + 1 + )); + continue; + } + }; + if led_bulb_data.len() != expected_len { + errors.push(format!( + "LED bulbs length mismatch for dancer #{} part #{}: got {}, expected {}", + index + 1, + part_index + 1, + led_bulb_data.len(), + expected_len + )); + } + for (bulb_index, bulb_data) in led_bulb_data.iter().enumerate() { + if bulb_data.len() != 2 { + errors.push(format!( + "Bulb data must be [color_id, alpha] for dancer #{} part #{} bulb #{}", + index + 1, part_index + 1, bulb_index + 1 + )); + continue; + } + let bulb_color_id = bulb_data[0]; + let bulb_alpha = bulb_data[1]; + + if bulb_color_id != -1 && !all_color_ids.contains(&bulb_color_id) { + errors.push(format!( + "Invalid bulb_color_id {} for dancer #{} part #{} bulb #{}", + bulb_color_id, index + 1, part_index + 1, bulb_index + 1 + )); + } + if bulb_alpha < 0 || bulb_alpha > 255 { + errors.push(format!( + "Invalid bulb_alpha {} for dancer #{} part #{} bulb #{}", + bulb_alpha, index + 1, part_index + 1, bulb_index + 1 + )); + } + } } - // check if the effect is valid - if !all_led_effect_ids.contains(&effect_id) - && effect_id != -1 - && effect_id != 0 - { - let error_message = format!( - "Effect of dancer #{} part #{} is not a valid effect", - index + 1, - part_index + 1 - ); - errors.push(error_message); + COLOR => { + errors.push(format!( + "LED part does not support COLOR. Got type = COLOR at dancer #{} part #{}", + index + 1, part_index + 1 + )); } + _ => {} + } } - }; + } } } @@ -391,127 +458,162 @@ impl ControlMapMutation { let part_type = &part.part_type; let led_bulb_data = &led_bulb_data[_index]; + let control_type = _data[0]; + let id_value = _data[1]; + let alpha = _data[2]; + let fade_bool = _data[3] == 1; + match part_type { // if the part is Fiber, update the color and alpha PartType::FIBER => { - let color_id = _data[0]; - let alpha = _data[1]; - - sqlx::query!( - r#" - UPDATE ControlData - SET color_id = ?, alpha = ? - WHERE frame_id = ? AND part_id = ? AND dancer_id = ?; - "#, - color_id, - alpha, - frame_id, - part.part_id, - dancer_id, - ) - .execute(mysql) - .await?; - } - // if the part is LED, update the effect and alpha - PartType::LED => { - let effect_id = _data[0]; - - if effect_id == 0 { - // LED bulbs - for (i, bulb_data) in led_bulb_data.iter().enumerate() { - let color_id = bulb_data[0]; - let alpha = bulb_data[1]; - - // check if led bulb exists - let is_led_bulb_exists = sqlx::query!( + match control_type { + NO_EFFECT => { + sqlx::query!( r#" - SELECT id FROM LEDBulb - WHERE control_id = ? AND position = ? + UPDATE ControlData + SET type = "NO_EFFECT", + fade = NULL, + color_id = NULL, + effect_id = NULL, + alpha = NULL + WHERE frame_id = ? AND part_id = ? AND dancer_id = ?; "#, - part.control_id, - i as i32 + frame_id, + part.part_id, + dancer_id ) - .fetch_optional(mysql) + .execute(&mut *tx) .await?; - - if is_led_bulb_exists.is_none() { - // insert led bulb - sqlx::query!( - r#" - INSERT INTO LEDBulb (control_id, position, color_id, alpha) - VALUES (?, ?, ?, ?) - "#, - part.control_id, - i as i32, - color_id, - alpha - ).execute(mysql).await?; - } else { - sqlx::query!( - r#" - UPDATE LEDBulb - SET color_id = ?, alpha = ? - WHERE control_id = ? AND position = ?; - "#, - color_id, - alpha, - part.control_id, - i as i32 - ) - .execute(mysql) - .await?; - } - + } + COLOR => { sqlx::query!( r#" UPDATE ControlData - SET effect_id = NULL, alpha = ?, type = "LED_BULBS" + SET type = "COLOR", + fade = ?, + color_id = ?, + effect_id = NULL, + alpha = ? WHERE frame_id = ? AND part_id = ? AND dancer_id = ?; "#, + fade_bool, + id_value, alpha, frame_id, part.part_id, - dancer_id, + dancer_id ) - .execute(mysql) + .execute(&mut *tx) .await?; } - } else { - // LED effect - let alpha = _data[1]; + _ => unreachable!("validated"), + } + } + PartType::LED => { + match control_type { + NO_EFFECT => { + sqlx::query!( + // delete bulbs + r#"DELETE FROM LEDBulb WHERE control_id = ?;"#, + part.control_id + ) + .execute(&mut *tx) + .await?; - if effect_id > 0 { sqlx::query!( r#" UPDATE ControlData - SET effect_id = ?, alpha = ?, type = "EFFECT" + SET type = "NO_EFFECT", + fade = NULL, + color_id = NULL, + effect_id = NULL, + alpha = NULL WHERE frame_id = ? AND part_id = ? AND dancer_id = ?; "#, - effect_id, + frame_id, + part.part_id, + dancer_id + ) + .execute(&mut *tx) + .await?; + } + EFFECT => { + sqlx::query!( + r#" + UPDATE ControlData + SET type = "EFFECT", + fade = ?, + color_id = NULL, + effect_id = ?, + alpha = ? + WHERE frame_id = ? AND part_id = ? AND dancer_id = ?; + "#, + fade_bool, + id_value, alpha, frame_id, part.part_id, - dancer_id, + dancer_id ) - .execute(mysql) + .execute(&mut *tx) .await?; - } else { + } + LED_BULBS => { + // update ControlData sqlx::query!( r#" UPDATE ControlData - SET effect_id = NULL, alpha = ?, type = "EFFECT" + SET type = "LED_BULBS", + fade = ?, + color_id = NULL, + effect_id = NULL, + alpha = ? WHERE frame_id = ? AND part_id = ? AND dancer_id = ?; "#, + fade_bool, alpha, frame_id, part.part_id, - dancer_id, + dancer_id ) - .execute(mysql) + .execute(&mut *tx) .await?; + + // replace bulbs wholesale + sqlx::query!( + r#"DELETE FROM LEDBulb WHERE control_id = ?;"#, + part.control_id + ) + .execute(&mut *tx) + .await?; + + // update LEDBulb data + for (bulb_index, bulb_data) in led_bulb_data.iter().enumerate() { + let bulb_color_id = if bulb_data[0] == -1 { + None + } else { + Some(bulb_data[0]) + }; + let bulb_alpha = bulb_data[1]; + + sqlx::query!( + r#" + INSERT INTO LEDBulb (control_id, position, color_id, alpha) + VALUES (?, ?, ?, ?); + "#, + part.control_id, + bulb_index as i32, + bulb_color_id, + bulb_alpha + ) + .execute(&mut *tx) + .await?; + } } + _ => unreachable!("validated"), } } + }; } } @@ -520,15 +622,18 @@ impl ControlMapMutation { sqlx::query!( r#" UPDATE ControlFrame - SET data_rev = data_rev + 1, fade = ? + SET data_rev = data_rev + 1, fade_for_new_status = ? WHERE id = ?; "#, input.fade.unwrap_or(false), frame_id, ) - .execute(mysql) + .execute(&mut *tx) .await?; + // commit the transaction + tx.commit().await?; + // update redis update_redis_control(mysql, &clients.redis_client, frame_id).await?; let redis_control = get_redis_control(&clients.redis_client, frame_id).await?; diff --git a/editor-server/src/graphql/mutations/part.rs b/editor-server/src/graphql/mutations/part.rs index 4d5d56599..28291d6fc 100644 --- a/editor-server/src/graphql/mutations/part.rs +++ b/editor-server/src/graphql/mutations/part.rs @@ -155,7 +155,16 @@ impl PartMutation { let _all_dancer_pos = sqlx::query_as!( PositionData, r#" - SELECT * FROM PositionData + SELECT + dancer_id, + frame_id, + COALESCE(x, 0) AS x, + COALESCE(y, 0) AS y, + COALESCE(z, 0) AS z, + rx, + ry, + rz + FROM PositionData WHERE dancer_id = ? ORDER BY frame_id ASC; "#, diff --git a/editor-server/src/graphql/mutations/position_frame.rs b/editor-server/src/graphql/mutations/position_frame.rs index c0a040d35..d10300a18 100644 --- a/editor-server/src/graphql/mutations/position_frame.rs +++ b/editor-server/src/graphql/mutations/position_frame.rs @@ -47,6 +47,8 @@ impl PositionFrameMutation { tracing::info!("Mutation: addPositionFrame"); + let mut tx = mysql.begin().await?; + let check = sqlx::query_as!( PositionFrameData, r#" @@ -55,7 +57,7 @@ impl PositionFrameMutation { "#, start ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await?; if let Some(check) = check { @@ -73,9 +75,13 @@ impl PositionFrameMutation { ORDER BY id ASC; "# ) - .fetch_all(mysql) + .fetch_all(&mut *tx) .await?; + // type constants + const NO_EFFECT: i32 = 0; + const POSITION: i32 = 1; + if let Some(data) = &position_data { if (*data).len() != dancers.len() { return Err(format!( @@ -85,12 +91,26 @@ impl PositionFrameMutation { .into()); } let mut errors = Vec::::new(); + for (idx, coor) in (*data).iter().enumerate() { - if coor.len() != 6 { + // 7 elements: [type, x, y, z, rx, ry, rz] + if coor.len() != 7 { + errors.push(format!( + "Dancer #{} data must have 7 elements [type, x, y, z, rx, ry, rz]. Got: {}", + idx + 1, + coor.len() + )); + continue; + } + + let type_value = coor[0] as i32; + + // validate type value + if type_value != NO_EFFECT && type_value != POSITION { errors.push(format!( - "Not all coordinates in dancer #{} in payload. Missing number: {}", - idx, - 6 - coor.len() + "Invalid type value {} for dancer #{}. Must be 0 (NO_EFFECT) or 1 (POSITION).", + type_value, + idx + 1 )); } } @@ -107,7 +127,7 @@ impl PositionFrameMutation { "#, start ) - .execute(mysql) + .execute(&mut *tx) .await? .last_insert_id() as i32; @@ -115,39 +135,56 @@ impl PositionFrameMutation { match &position_data { Some(data) => { + let mut location = Vec::new(); + let mut rotation = Vec::new(); for (idx, coor) in (*data).iter().enumerate() { - let _ = sqlx::query!( - r#" - INSERT INTO PositionData (dancer_id, frame_id, x, y, z, rx, ry, rz) - VALUES (?, ?, ?, ?, ?, ?, ?, ?); - "#, - dancers[idx].id, - id, - coor[0], - coor[1], - coor[2], - coor[3], - coor[4], - coor[5], - ) - .execute(mysql) - .await?; + let type_value = coor[0] as i32; + if type_value == NO_EFFECT { + let _ = sqlx::query!( + r#" + INSERT INTO PositionData (dancer_id, frame_id, type, x, y, z, rx, ry, rz) + VALUES (?, ?, ?, NULL, NULL, NULL, 0, 0, 0); + "#, + dancers[idx].id, + id, + "NO_EFFECT" + ) + .execute(&mut *tx) + .await?; + + location.push([0.0, 0.0, 0.0]); + rotation.push([0.0, 0.0, 0.0]); + } else { + let _ = sqlx::query!( + r#" + INSERT INTO PositionData (dancer_id, frame_id, type, x, y, z, rx, ry, rz) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?); + "#, + dancers[idx].id, + id, + "POSITION", + coor[1], + coor[2], + coor[3], + coor[4], + coor[5], + coor[6], + ) + .execute(&mut *tx) + .await?; + + location.push([coor[1], coor[2], coor[3]]); + rotation.push([coor[4], coor[5], coor[6]]); + } } - create_frames.insert( id.to_string(), RedisPosition { start, editing: None, rev: Revision::default(), - location: data - .iter() - .map(|coor| [coor[0], coor[1], coor[2]]) - .collect(), - rotation: data - .iter() - .map(|coor| [coor[3], coor[4], coor[5]]) - .collect(), + location, + rotation, }, ); } @@ -155,11 +192,12 @@ impl PositionFrameMutation { for dancer in dancers { let _ = sqlx::query!( r#" - INSERT INTO PositionData (dancer_id, frame_id, x, y, z, rx, ry, rz) - VALUES (?, ?, ?, ?, ?, ?, ?, ?); + INSERT INTO PositionData (dancer_id, frame_id, type, x, y, z, rx, ry, rz) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?); "#, dancer.id, id, + "POSITION", 0.0, 0.0, 0.0, @@ -167,12 +205,14 @@ impl PositionFrameMutation { 0.0, 0.0, ) - .execute(mysql) + .execute(&mut *tx) .await?; } } } + tx.commit().await?; + update_redis_position(mysql, redis, id).await?; // subscription @@ -237,6 +277,8 @@ impl PositionFrameMutation { tracing::info!("Mutation: editPositionFrame"); + let mut tx = mysql.begin().await?; + let check = sqlx::query_as!( PositionFrameData, r#" @@ -245,7 +287,7 @@ impl PositionFrameMutation { "#, input.start ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await?; if let Some(check) = check { @@ -266,7 +308,7 @@ impl PositionFrameMutation { "#, input.frame_id ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await?; if let Some(frame_to_edit) = frame_to_edit { @@ -285,7 +327,7 @@ impl PositionFrameMutation { "#, input.frame_id ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await?; match position_frame { @@ -305,7 +347,7 @@ impl PositionFrameMutation { input.start, input.frame_id ) - .execute(mysql) + .execute(&mut *tx) .await?; let _ = sqlx::query_as!( @@ -317,7 +359,7 @@ impl PositionFrameMutation { "#, context.user_id ) - .execute(mysql) + .execute(&mut *tx) .await?; // update revision of the frame @@ -330,9 +372,11 @@ impl PositionFrameMutation { "#, input.frame_id ) - .execute(mysql) + .execute(&mut *tx) .await?; + tx.commit().await?; + let position_frame = position_frame.unwrap(); update_redis_position(mysql, redis, position_frame.id).await?; @@ -404,6 +448,8 @@ impl PositionFrameMutation { tracing::info!("Mutation: deletePositionFrame"); + let mut tx = mysql.begin().await?; + let frame_to_delete = sqlx::query_as!( EditingPositionFrameData, r#" @@ -412,7 +458,7 @@ impl PositionFrameMutation { "#, input.frame_id ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await?; if let Some(frame_to_delete) = frame_to_delete { @@ -431,7 +477,7 @@ impl PositionFrameMutation { "#, input.frame_id ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await?; if deleted_frame.is_none() { @@ -446,7 +492,7 @@ impl PositionFrameMutation { "#, input.frame_id ) - .execute(mysql) + .execute(&mut *tx) .await?; let _ = sqlx::query_as!( @@ -458,9 +504,11 @@ impl PositionFrameMutation { "#, context.user_id ) - .execute(mysql) + .execute(&mut *tx) .await?; + tx.commit().await?; + // subscription let map_payload = PositionMapPayload { edit_by: context.user_id, diff --git a/editor-server/src/graphql/mutations/position_map.rs b/editor-server/src/graphql/mutations/position_map.rs index ba3cc960a..d481012a2 100644 --- a/editor-server/src/graphql/mutations/position_map.rs +++ b/editor-server/src/graphql/mutations/position_map.rs @@ -42,6 +42,8 @@ impl PositionMapMutation { tracing::info!("Mutation: editPosMap"); + let mut tx = mysql.begin().await?; + //check payload correctness let frame_to_edit = sqlx::query_as!( PositionFrameData, @@ -51,7 +53,7 @@ impl PositionMapMutation { "#, input.frame_id ) - .fetch_one(mysql) + .fetch_one(&mut *tx) .await?; let editing = sqlx::query_as!( @@ -62,7 +64,7 @@ impl PositionMapMutation { "#, frame_to_edit.id ) - .fetch_optional(mysql) + .fetch_optional(&mut *tx) .await?; // to check if the frame is editing by other user @@ -79,7 +81,7 @@ impl PositionMapMutation { ORDER BY id ASC; "# ) - .fetch_all(mysql) + .fetch_all(&mut *tx) .await?; if input.position_data.len() != dancers.len() { @@ -90,29 +92,77 @@ impl PositionMapMutation { .into()); } + const NO_EFFECT: i32 = 0; + const POSITION: i32 = 1; + + let mut errors = Vec::::new(); + // update position data - for (ind, coor) in input.position_data.iter().enumerate() { - let dancer = &dancers[ind]; - let _ = sqlx::query!( - r#" - UPDATE PositionData - SET x = ?, y = ?, z = ?, rx = ?, ry = ?, rz = ? - WHERE dancer_id = ? AND frame_id = ?; - "#, - coor[0], - coor[1], - coor[2], - coor[3], - coor[4], - coor[5], - dancer.id, - frame_to_edit.id - ) - .execute(mysql) - .await?; + for (idx, coor) in input.position_data.iter().enumerate() { + // 7 elements: [type, x, y, z, rx, ry, rz] + if coor.len() != 7 { + errors.push(format!( + "Dancer #{} data must have 7 elements [type, x, y, z, rx, ry, rz]. Got: {}", + idx + 1, + coor.len() + )); + continue; + } + + let type_value = coor[0] as i32; + + if type_value != NO_EFFECT && type_value != POSITION { + errors.push(format!( + "Invalid type value {} for dancer #{}. Must be 0 (NO_EFFECT) or 1 (POSITION).", + type_value, + idx + 1 + )); + } + } + if !errors.is_empty() { + return Err(errors.join("; ").into()); } // update editing position frame + for (idx, coor) in input.position_data.iter().enumerate() { + let dancer = &dancers[idx]; + let type_value = coor[0] as i32; + + if type_value == NO_EFFECT { + let _ = sqlx::query!( + r#" + UPDATE PositionData + SET type = ?, x = NULL, y = NULL, z = NULL, rx = 0, ry = 0, rz = 0 + WHERE dancer_id = ? AND frame_id = ?; + "#, + "NO_EFFECT", + dancer.id, + frame_to_edit.id + ) + .execute(&mut *tx) + .await?; + } else { + let _ = sqlx::query!( + r#" + UPDATE PositionData + SET type = ?, x = ?, y = ?, z = ?, rx = ?, ry = ?, rz = ? + WHERE dancer_id = ? AND frame_id = ?; + "#, + "POSITION", + coor[1], + coor[2], + coor[3], + coor[4], + coor[5], + coor[6], + dancer.id, + frame_to_edit.id + ) + .execute(&mut *tx) + .await?; + } + } + let _ = sqlx::query!( r#" UPDATE EditingPositionFrame @@ -121,9 +171,11 @@ impl PositionMapMutation { "#, context.user_id ) - .execute(mysql) + .execute(&mut *tx) .await?; + tx.commit().await?; + update_redis_position(mysql, redis, frame_to_edit.id).await?; let redis_position = get_redis_position(redis, frame_to_edit.id).await?; let update_frames = HashMap::from([(frame_to_edit.id.to_string(), redis_position)]); diff --git a/editor-server/src/graphql/queries/control_frame.rs b/editor-server/src/graphql/queries/control_frame.rs index 18fc71854..3466eb760 100644 --- a/editor-server/src/graphql/queries/control_frame.rs +++ b/editor-server/src/graphql/queries/control_frame.rs @@ -27,7 +27,7 @@ impl ControlFrameQuery { SELECT id, start, - fade as "fade: bool", + fade_for_new_status as "fade: bool", meta_rev, data_rev FROM ControlFrame diff --git a/editor-server/src/lib.rs b/editor-server/src/lib.rs index ff47555f6..7512cf747 100644 --- a/editor-server/src/lib.rs +++ b/editor-server/src/lib.rs @@ -20,11 +20,11 @@ pub async fn init() { dotenv::dotenv().ok(); global::envs::set(); - let mysql_host = env!("DATABASE_URL", "DATABASE_URL is not set"); - let redis_host = env!("REDIS_HOST", "REDIS_HOST is not set"); - let redis_port = env!("REDIS_PORT", "REDIS_PORT is not set"); + let mysql_host = std::env::var("DATABASE_URL").expect("DATABASE_URL is not set"); + let redis_host = std::env::var("REDIS_HOST").unwrap_or_else(|_| "127.0.0.1".to_string()); + let redis_port = std::env::var("REDIS_PORT").unwrap_or_else(|_| "6379".to_string()); - global::clients::set(AppClients::connect(mysql_host, (redis_host, redis_port)).await); + global::clients::set(AppClients::connect(&mysql_host, (&redis_host, &redis_port)).await); let clients = global::clients::get(); diff --git a/editor-server/src/routes/api/export_data.rs b/editor-server/src/routes/api/export_data.rs index 2bf5f878e..ff9a9445a 100644 --- a/editor-server/src/routes/api/export_data.rs +++ b/editor-server/src/routes/api/export_data.rs @@ -212,7 +212,7 @@ pub async fn export_data( SELECT id, start, - fade as "fade: bool", + fade_for_new_status as "fade: bool", meta_rev, data_rev FROM ControlFrame diff --git a/editor-server/src/routes/api/get_dancer_fiber_data.rs b/editor-server/src/routes/api/get_dancer_fiber_data.rs index 9d47da2c3..8b78fbb66 100644 --- a/editor-server/src/routes/api/get_dancer_fiber_data.rs +++ b/editor-server/src/routes/api/get_dancer_fiber_data.rs @@ -139,9 +139,9 @@ pub async fn get_dancer_fiber_data( SELECT ControlFrame.id, ControlFrame.start, - ControlFrame.fade, + ControlFrame.fade_for_new_status AS fade, ControlData.color_id, - ControlData.alpha, + COALESCE(ControlData.alpha, 0) AS "alpha: i32", Part.name FROM Dancer INNER JOIN Model diff --git a/editor-server/src/routes/api/get_dancer_led_data.rs b/editor-server/src/routes/api/get_dancer_led_data.rs index e964f65a1..aa09723b6 100644 --- a/editor-server/src/routes/api/get_dancer_led_data.rs +++ b/editor-server/src/routes/api/get_dancer_led_data.rs @@ -370,7 +370,7 @@ pub async fn get_dancer_led_data( ControlData.type, ControlData.effect_id, ControlFrame.start, - ControlFrame.fade + ControlFrame.fade_for_new_status AS fade FROM Dancer INNER JOIN Model ON Dancer.model_id = Model.id @@ -401,7 +401,7 @@ pub async fn get_dancer_led_data( ControlData.id as "control_data_id", LEDBulb.position, LEDBulb.color_id, - LEDBulb.alpha + LEDBulb.alpha AS "alpha: i32" FROM Dancer INNER JOIN Model ON Dancer.model_id = Model.id diff --git a/editor-server/src/routes/api/upload_data.rs b/editor-server/src/routes/api/upload_data.rs index bddc23c0f..45f6148a2 100644 --- a/editor-server/src/routes/api/upload_data.rs +++ b/editor-server/src/routes/api/upload_data.rs @@ -367,7 +367,7 @@ pub async fn upload_data( let frame_id = sqlx::query!( r#" - INSERT INTO ControlFrame (start, fade) + INSERT INTO ControlFrame (start, fade_for_new_status) VALUES (?, ?); "#, frame_obj.start, diff --git a/editor-server/src/utils/data.rs b/editor-server/src/utils/data.rs index 1ee1ae9d9..a7d52e51c 100644 --- a/editor-server/src/utils/data.rs +++ b/editor-server/src/utils/data.rs @@ -1,6 +1,7 @@ //! Database setting utilities. use crate::db::types::control_data::ControlType; +// use crate::db::types::dancer; use crate::global; use crate::types::global::{PartControl, PartType, RedisControl, RedisPosition, Revision}; use crate::utils::vector::partition_by_field; @@ -18,7 +19,13 @@ pub async fn init_redis_control( let frames = sqlx::query!( r#" - SELECT ControlFrame.*, EditingControlFrame.user_id AS user_id + SELECT + ControlFrame.id, + ControlFrame.start, + ControlFrame.meta_rev, + ControlFrame.data_rev, + ControlFrame.fade_for_new_status AS fade, + EditingControlFrame.user_id AS user_id FROM ControlFrame LEFT JOIN EditingControlFrame ON ControlFrame.id = EditingControlFrame.frame_id; @@ -40,8 +47,9 @@ pub async fn init_redis_control( ControlData.type AS "type: ControlType", ControlData.color_id, ControlData.effect_id, - ControlData.alpha, - LEDBulb.color_id AS bulb_color_id + COALESCE(ControlData.alpha, 0) AS "alpha: i32", + LEDBulb.color_id AS bulb_color_id, + COALESCE(LEDBulb.alpha, 0) AS "bulb_alpha: i32" FROM Dancer INNER JOIN Model ON Dancer.model_id = Model.id @@ -100,6 +108,11 @@ pub async fn init_redis_control( } match part_control[0].r#type { + ControlType::NoEffect => { + // NO_EFFECT: Use -1 as the ID to indicate "no effect" + dancer_status.push(PartControl(-1, 0)); + dancer_led_status.push(Vec::new()); + } ControlType::Effect => { dancer_status.push(PartControl( part_control[0].effect_id.unwrap_or(-1), @@ -110,7 +123,7 @@ pub async fn init_redis_control( ControlType::LEDBulbs => { let bulbs = part_control .iter() - .map(|data| (data.bulb_color_id.unwrap_or(-1), data.alpha)) + .map(|data| (data.bulb_color_id.unwrap_or(-1), data.bulb_alpha)) .collect_vec(); dancer_status.push(PartControl(0, part_control[0].alpha)); @@ -166,7 +179,12 @@ pub async fn init_redis_position( let frames = sqlx::query!( r#" - SELECT PositionFrame.*, EditingPositionFrame.user_id AS user_id + SELECT + PositionFrame.id, + PositionFrame.start, + PositionFrame.meta_rev, + PositionFrame.data_rev, + EditingPositionFrame.user_id AS user_id FROM PositionFrame LEFT JOIN EditingPositionFrame ON PositionFrame.id = EditingPositionFrame.frame_id; @@ -184,9 +202,10 @@ pub async fn init_redis_position( SELECT Dancer.id, PositionData.frame_id, - PositionData.x, - PositionData.y, - PositionData.z, + PositionData.type AS "position_type: String", + COALESCE(PositionData.x, 0.0) AS "x!: f64", + COALESCE(PositionData.y, 0.0) AS "y!: f64", + COALESCE(PositionData.z, 0.0) AS "z!: f64", PositionData.rx, PositionData.ry, PositionData.rz @@ -266,7 +285,13 @@ pub async fn update_redis_control( let frame = sqlx::query!( r#" - SELECT ControlFrame.*, EditingControlFrame.user_id AS user_id + SELECT + ControlFrame.id, + ControlFrame.start, + ControlFrame.meta_rev, + ControlFrame.data_rev, + ControlFrame.fade_for_new_status AS fade, + EditingControlFrame.user_id AS user_id FROM ControlFrame LEFT JOIN EditingControlFrame ON ControlFrame.id = EditingControlFrame.frame_id @@ -294,10 +319,10 @@ pub async fn update_redis_control( ControlData.id AS control_id, ControlData.effect_id, ControlData.color_id, - ControlData.alpha, + COALESCE(ControlData.alpha, 0) AS "alpha: i32", ControlData.type AS "type: ControlType", LEDBulb.color_id AS bulb_color_id, - LEDBulb.alpha AS bulb_alpha + COALESCE(LEDBulb.alpha, 0) AS "bulb_alpha: i32" FROM Dancer INNER JOIN Model ON Dancer.model_id = Model.id @@ -343,6 +368,11 @@ pub async fn update_redis_control( } match part_control[0].r#type { + ControlType::NoEffect => { + // NO_EFFECT: Use -1 as the ID to indicate "no effect" + dancer_status.push(PartControl(-1, 0)); + dancer_led_status.push(Vec::new()); + } ControlType::Effect => { dancer_status.push(PartControl( part_control[0].effect_id.unwrap_or(-1), @@ -356,7 +386,7 @@ pub async fn update_redis_control( .map(|data| { ( data.bulb_color_id.unwrap_or(-1), - data.bulb_alpha.unwrap_or(0), + data.bulb_alpha, ) }) .collect_vec(); @@ -410,7 +440,12 @@ pub async fn update_redis_position( let frame = sqlx::query!( r#" - SELECT PositionFrame.*, EditingPositionFrame.user_id AS user_id + SELECT + PositionFrame.id, + PositionFrame.start, + PositionFrame.meta_rev, + PositionFrame.data_rev, + EditingPositionFrame.user_id AS user_id FROM PositionFrame LEFT JOIN EditingPositionFrame ON PositionFrame.id = EditingPositionFrame.frame_id @@ -433,9 +468,9 @@ pub async fn update_redis_position( SELECT Dancer.id, PositionData.frame_id, - PositionData.x, - PositionData.y, - PositionData.z, + COALESCE(PositionData.x, 0) AS x, + COALESCE(PositionData.y, 0) AS y, + COALESCE(PositionData.z, 0) AS z, PositionData.rx, PositionData.ry, PositionData.rz diff --git a/prod-support/editor-server/Dockerfile b/prod-support/editor-server/Dockerfile index 767fe9405..6fd71ffa1 100644 --- a/prod-support/editor-server/Dockerfile +++ b/prod-support/editor-server/Dockerfile @@ -4,18 +4,9 @@ RUN cargo new editor-server WORKDIR /editor-server COPY ./editor-server/.cargo ./.cargo -RUN echo '\n\n[workspace]\nmembers = ["prisma"]\n' >> ./Cargo.toml - -RUN mkdir ./prisma -COPY ./editor-server/prisma/schema.prisma ./prisma/schema.prisma -COPY ./editor-server/prisma/Cargo.toml ./prisma/Cargo.toml -COPY ./editor-server/prisma/src ./prisma/src - -RUN cargo prisma validate - -COPY ./editor-server/prisma/migrations ./prisma/migrations COPY ./editor-server/Cargo.toml . COPY ./editor-server/Cargo.lock . +COPY ./editor-server/sea-orm ./sea-orm RUN cargo fetch RUN rm -r ./src @@ -23,5 +14,4 @@ RUN rm -r ./src COPY ./editor-server/.env.production ./.env COPY ./editor-server/src ./src -CMD ["bash", "-c", "./target/debug/prisma migrate deploy && cargo run --release"] - +CMD ["bash", "-c", "cargo run -p migration --release -- up && cargo run --release"] diff --git a/sea-orm/src/entity/color.rs b/sea-orm/src/entity/color.rs new file mode 100644 index 000000000..9af899002 --- /dev/null +++ b/sea-orm/src/entity/color.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Color")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub name: String, + pub r: i32, + pub g: i32, + pub b: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::control_data::Entity")] + ControlData, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/control_data.rs b/sea-orm/src/entity/control_data.rs new file mode 100644 index 000000000..131f27a96 --- /dev/null +++ b/sea-orm/src/entity/control_data.rs @@ -0,0 +1,105 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use super::sea_orm_active_enums::Type; +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "ControlData")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique_key = "ControlData_dancer_id_part_id_frame_id_key")] + pub dancer_id: i32, + #[sea_orm(unique_key = "ControlData_dancer_id_part_id_frame_id_key")] + pub part_id: i32, + #[sea_orm(unique_key = "ControlData_dancer_id_part_id_frame_id_key")] + pub frame_id: i32, + pub r#type: Type, + pub color_id: Option, + pub effect_id: Option, + pub alpha: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::color::Entity", + from = "Column::ColorId", + to = "super::color::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Color, + #[sea_orm( + belongs_to = "super::control_frame::Entity", + from = "Column::FrameId", + to = "super::control_frame::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + ControlFrame, + #[sea_orm( + belongs_to = "super::dancer::Entity", + from = "Column::DancerId", + to = "super::dancer::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Dancer, + #[sea_orm(has_many = "super::led_bulb::Entity")] + LedBulb, + #[sea_orm( + belongs_to = "super::led_effect::Entity", + from = "Column::EffectId", + to = "super::led_effect::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + LedEffect, + #[sea_orm( + belongs_to = "super::part::Entity", + from = "Column::PartId", + to = "super::part::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Part, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Color.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlFrame.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Dancer.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedBulb.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffect.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Part.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/control_frame.rs b/sea-orm/src/entity/control_frame.rs new file mode 100644 index 000000000..ef3c54a0d --- /dev/null +++ b/sea-orm/src/entity/control_frame.rs @@ -0,0 +1,37 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "ControlFrame")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub start: i32, + pub fade: i8, + pub meta_rev: i32, + pub data_rev: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::control_data::Entity")] + ControlData, + #[sea_orm(has_one = "super::editing_control_frame::Entity")] + EditingControlFrame, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::EditingControlFrame.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/dancer.rs b/sea-orm/src/entity/dancer.rs new file mode 100644 index 000000000..461a79922 --- /dev/null +++ b/sea-orm/src/entity/dancer.rs @@ -0,0 +1,58 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Dancer")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub name: String, + pub model_id: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::control_data::Entity")] + ControlData, + #[sea_orm( + belongs_to = "super::model::Entity", + from = "Column::ModelId", + to = "super::model::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Model, + #[sea_orm(has_many = "super::position_data::Entity")] + PositionData, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Model.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PositionData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::position_data::Relation::PositionFrame.def() + } + fn via() -> Option { + Some(super::position_data::Relation::Dancer.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/editing_control_frame.rs b/sea-orm/src/entity/editing_control_frame.rs new file mode 100644 index 000000000..9fa4c07ce --- /dev/null +++ b/sea-orm/src/entity/editing_control_frame.rs @@ -0,0 +1,32 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "EditingControlFrame")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false, unique)] + pub user_id: i32, + #[sea_orm(unique)] + pub frame_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::control_frame::Entity", + from = "Column::FrameId", + to = "super::control_frame::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + ControlFrame, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlFrame.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/editing_led_effect.rs b/sea-orm/src/entity/editing_led_effect.rs new file mode 100644 index 000000000..dc404c5c8 --- /dev/null +++ b/sea-orm/src/entity/editing_led_effect.rs @@ -0,0 +1,32 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "EditingLEDEffect")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub user_id: i32, + #[sea_orm(unique)] + pub led_effect_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::led_effect::Entity", + from = "Column::LedEffectId", + to = "super::led_effect::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + LedEffect, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffect.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/editing_position_frame.rs b/sea-orm/src/entity/editing_position_frame.rs new file mode 100644 index 000000000..b8f66aa60 --- /dev/null +++ b/sea-orm/src/entity/editing_position_frame.rs @@ -0,0 +1,32 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "EditingPositionFrame")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub user_id: i32, + #[sea_orm(unique)] + pub frame_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::position_frame::Entity", + from = "Column::FrameId", + to = "super::position_frame::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + PositionFrame, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PositionFrame.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/effect_list_data.rs b/sea-orm/src/entity/effect_list_data.rs new file mode 100644 index 000000000..cdaa8645a --- /dev/null +++ b/sea-orm/src/entity/effect_list_data.rs @@ -0,0 +1,18 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "EffectListData")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub start: i32, + pub end: i32, + pub description: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/led_bulb.rs b/sea-orm/src/entity/led_bulb.rs new file mode 100644 index 000000000..e2dee7609 --- /dev/null +++ b/sea-orm/src/entity/led_bulb.rs @@ -0,0 +1,34 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "LEDBulb")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub control_id: i32, + pub position: i32, + pub color_id: i32, + pub alpha: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::control_data::Entity", + from = "Column::ControlId", + to = "super::control_data::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + ControlData, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/led_effect.rs b/sea-orm/src/entity/led_effect.rs new file mode 100644 index 000000000..1f0f64116 --- /dev/null +++ b/sea-orm/src/entity/led_effect.rs @@ -0,0 +1,74 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "LEDEffect")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique_key = "LEDEffect_name_model_id_part_id_key")] + pub name: String, + #[sea_orm(unique_key = "LEDEffect_name_model_id_part_id_key")] + pub model_id: i32, + #[sea_orm(unique_key = "LEDEffect_name_model_id_part_id_key")] + pub part_id: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::control_data::Entity")] + ControlData, + #[sea_orm(has_one = "super::editing_led_effect::Entity")] + EditingLedEffect, + #[sea_orm(has_many = "super::led_effect_state::Entity")] + LedEffectState, + #[sea_orm( + belongs_to = "super::model::Entity", + from = "Column::ModelId", + to = "super::model::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Model, + #[sea_orm( + belongs_to = "super::part::Entity", + from = "Column::PartId", + to = "super::part::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Part, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::EditingLedEffect.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffectState.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Model.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Part.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/led_effect_state.rs b/sea-orm/src/entity/led_effect_state.rs new file mode 100644 index 000000000..b4d17e068 --- /dev/null +++ b/sea-orm/src/entity/led_effect_state.rs @@ -0,0 +1,36 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "LEDEffectState")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique_key = "LEDEffectState_effect_id_position_key")] + pub effect_id: i32, + #[sea_orm(unique_key = "LEDEffectState_effect_id_position_key")] + pub position: i32, + pub color_id: i32, + pub alpha: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::led_effect::Entity", + from = "Column::EffectId", + to = "super::led_effect::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + LedEffect, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffect.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/logger.rs b/sea-orm/src/entity/logger.rs new file mode 100644 index 000000000..dd8f63cb9 --- /dev/null +++ b/sea-orm/src/entity/logger.rs @@ -0,0 +1,22 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Logger")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub user: i32, + pub variable_value: Option, + pub field_name: String, + pub time: DateTime, + pub status: String, + pub error_message: Option, + pub result: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/mod.rs b/sea-orm/src/entity/mod.rs new file mode 100644 index 000000000..1350d07a2 --- /dev/null +++ b/sea-orm/src/entity/mod.rs @@ -0,0 +1,22 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +pub mod prelude; + +pub mod color; +pub mod control_data; +pub mod control_frame; +pub mod dancer; +pub mod editing_control_frame; +pub mod editing_led_effect; +pub mod editing_position_frame; +pub mod effect_list_data; +pub mod led_bulb; +pub mod led_effect; +pub mod led_effect_state; +pub mod logger; +pub mod model; +pub mod part; +pub mod position_data; +pub mod position_frame; +pub mod revision; +pub mod sea_orm_active_enums; diff --git a/sea-orm/src/entity/model.rs b/sea-orm/src/entity/model.rs new file mode 100644 index 000000000..be53cef24 --- /dev/null +++ b/sea-orm/src/entity/model.rs @@ -0,0 +1,42 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Model")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub name: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::dancer::Entity")] + Dancer, + #[sea_orm(has_many = "super::led_effect::Entity")] + LedEffect, + #[sea_orm(has_many = "super::part::Entity")] + Part, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Dancer.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffect.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Part.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/part.rs b/sea-orm/src/entity/part.rs new file mode 100644 index 000000000..c9302b02b --- /dev/null +++ b/sea-orm/src/entity/part.rs @@ -0,0 +1,53 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use super::sea_orm_active_enums::Type; +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Part")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique_key = "Part_name_model_id_key")] + pub model_id: i32, + #[sea_orm(unique_key = "Part_name_model_id_key")] + pub name: String, + pub r#type: Type, + pub length: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::control_data::Entity")] + ControlData, + #[sea_orm(has_many = "super::led_effect::Entity")] + LedEffect, + #[sea_orm( + belongs_to = "super::model::Entity", + from = "Column::ModelId", + to = "super::model::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Model, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ControlData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LedEffect.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Model.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/position_data.rs b/sea-orm/src/entity/position_data.rs new file mode 100644 index 000000000..325f33667 --- /dev/null +++ b/sea-orm/src/entity/position_data.rs @@ -0,0 +1,58 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "PositionData")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub dancer_id: i32, + #[sea_orm(primary_key, auto_increment = false)] + pub frame_id: i32, + #[sea_orm(column_type = "Double")] + pub x: f64, + #[sea_orm(column_type = "Double")] + pub y: f64, + #[sea_orm(column_type = "Double")] + pub z: f64, + #[sea_orm(column_type = "Double")] + pub rx: f64, + #[sea_orm(column_type = "Double")] + pub ry: f64, + #[sea_orm(column_type = "Double")] + pub rz: f64, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::dancer::Entity", + from = "Column::DancerId", + to = "super::dancer::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Dancer, + #[sea_orm( + belongs_to = "super::position_frame::Entity", + from = "Column::FrameId", + to = "super::position_frame::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + PositionFrame, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Dancer.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PositionFrame.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/position_frame.rs b/sea-orm/src/entity/position_frame.rs new file mode 100644 index 000000000..3af699c36 --- /dev/null +++ b/sea-orm/src/entity/position_frame.rs @@ -0,0 +1,45 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "PositionFrame")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub start: i32, + pub meta_rev: i32, + pub data_rev: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_one = "super::editing_position_frame::Entity")] + EditingPositionFrame, + #[sea_orm(has_many = "super::position_data::Entity")] + PositionData, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::EditingPositionFrame.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PositionData.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::position_data::Relation::Dancer.def() + } + fn via() -> Option { + Some(super::position_data::Relation::PositionFrame.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/prelude.rs b/sea-orm/src/entity/prelude.rs new file mode 100644 index 000000000..de16880d1 --- /dev/null +++ b/sea-orm/src/entity/prelude.rs @@ -0,0 +1,19 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +pub use super::color::Entity as Color; +pub use super::control_data::Entity as ControlData; +pub use super::control_frame::Entity as ControlFrame; +pub use super::dancer::Entity as Dancer; +pub use super::editing_control_frame::Entity as EditingControlFrame; +pub use super::editing_led_effect::Entity as EditingLedEffect; +pub use super::editing_position_frame::Entity as EditingPositionFrame; +pub use super::effect_list_data::Entity as EffectListData; +pub use super::led_bulb::Entity as LedBulb; +pub use super::led_effect::Entity as LedEffect; +pub use super::led_effect_state::Entity as LedEffectState; +pub use super::logger::Entity as Logger; +pub use super::model::Entity as Model; +pub use super::part::Entity as Part; +pub use super::position_data::Entity as PositionData; +pub use super::position_frame::Entity as PositionFrame; +pub use super::revision::Entity as Revision; diff --git a/sea-orm/src/entity/revision.rs b/sea-orm/src/entity/revision.rs new file mode 100644 index 000000000..7c55813b5 --- /dev/null +++ b/sea-orm/src/entity/revision.rs @@ -0,0 +1,18 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] +#[sea_orm(table_name = "Revision")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub uuid: String, + pub time: DateTime, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/sea-orm/src/entity/sea_orm_active_enums.rs b/sea-orm/src/entity/sea_orm_active_enums.rs new file mode 100644 index 000000000..13cde541c --- /dev/null +++ b/sea-orm/src/entity/sea_orm_active_enums.rs @@ -0,0 +1,12 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0 + +use sea_orm::entity::prelude::*; + +#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "type")] +pub enum Type { + #[sea_orm(string_value = "LED")] + Led, + #[sea_orm(string_value = "FIBER")] + Fiber, +}