diff --git a/.gitignore b/.gitignore index 2a3c64d..a584c90 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ node_modules web/dist web/tmp adapters +plugins diff --git a/Cargo.lock b/Cargo.lock index e797820..102893e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" + [[package]] name = "account_manager" version = "0.1.0" @@ -291,6 +297,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "aliasable" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" + [[package]] name = "alloc-no-stdlib" version = "2.0.4" @@ -372,6 +384,16 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +[[package]] +name = "async-attributes" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "async-channel" version = "1.8.0" @@ -383,6 +405,114 @@ dependencies = [ "futures-core", ] +[[package]] +name = "async-executor" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" +dependencies = [ + "async-lock", + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" +dependencies = [ + "async-channel", + "async-executor", + "async-io", + "async-lock", + "blocking", + "futures-lite", + "once_cell", + "tokio 1.28.2", +] + +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock", + "autocfg 1.1.0", + "cfg-if 1.0.0", + "concurrent-queue", + "futures-lite", + "log", + "parking", + "polling", + "rustix 0.37.19", + "slab", + "socket2 0.4.9", + "waker-fn", +] + +[[package]] +name = "async-lock" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-std" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +dependencies = [ + "async-attributes", + "async-channel", + "async-global-executor", + "async-io", + "async-lock", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite 0.2.9", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite 0.2.9", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + [[package]] name = "async-stripe" version = "0.21.0" @@ -408,6 +538,12 @@ dependencies = [ "uuid 0.8.2", ] +[[package]] +name = "async-task" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" + [[package]] name = "async-trait" version = "0.1.68" @@ -437,6 +573,26 @@ dependencies = [ "autocfg 1.1.0", ] +[[package]] +name = "atomic-waker" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" + +[[package]] +name = "attohttpc" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fcf00bc6d5abb29b5f97e3c61a90b6d3caa12f3faf897d4a3e3607c050a35a7" +dependencies = [ + "http", + "log", + "native-tls", + "serde", + "serde_json", + "url", +] + [[package]] name = "atty" version = "0.2.14" @@ -463,6 +619,45 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "aws-creds" +version = "0.34.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3776743bb68d4ad02ba30ba8f64373f1be4e082fe47651767171ce75bb2f6cf5" +dependencies = [ + "attohttpc", + "dirs 4.0.0", + "log", + "quick-xml", + "rust-ini", + "serde", + "thiserror", + "time 0.3.20", + "url", +] + +[[package]] +name = "aws-region" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "056557a61427d0e5ba29dd931031c8ffed4ee7a550e7cd55692a9d8deb0a9dba" +dependencies = [ + "thiserror", +] + +[[package]] +name = "bae" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b8de67cc41132507eeece2584804efcb15f85ba516e34c944b7667f480397a" +dependencies = [ + "heck 0.3.3", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "base64" version = "0.13.1" @@ -531,6 +726,21 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blocking" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65" +dependencies = [ + "async-channel", + "async-lock", + "async-task", + "atomic-waker", + "fastrand", + "futures-lite", + "log", +] + [[package]] name = "borsh" version = "0.10.3" @@ -676,10 +886,12 @@ name = "cache-adapter" version = "0.1.0" dependencies = [ "async-trait", + "bincode", "config", "serde", "thiserror", "toml 0.7.4", + "tracing", ] [[package]] @@ -691,6 +903,7 @@ dependencies = [ "cache-adapter", "chrono", "futures-executor", + "plugin-api", "serde", "tokio 1.28.2", "tracing", @@ -869,11 +1082,47 @@ dependencies = [ "atty", "bitflags", "strsim 0.8.0", - "textwrap", + "textwrap 0.11.0", "unicode-width", "vec_map", ] +[[package]] +name = "clap" +version = "3.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +dependencies = [ + "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "once_cell", + "textwrap 0.16.0", +] + +[[package]] +name = "clap_derive" +version = "3.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" +dependencies = [ + "heck 0.4.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "cloudabi" version = "0.0.3" @@ -1439,6 +1688,12 @@ dependencies = [ "syn 2.0.15", ] +[[package]] +name = "dlv-list" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" + [[package]] name = "doc-comment" version = "0.3.3" @@ -1588,13 +1843,16 @@ dependencies = [ name = "event-bus-adapter" version = "0.1.0" dependencies = [ + "async-trait", "bincode", "config", "event-bus-messages", "futures 0.3.28", "serde", "thiserror", + "tokio 1.28.2", "toml 0.7.4", + "uuid 1.3.3", ] [[package]] @@ -1611,9 +1869,11 @@ dependencies = [ name = "event-bus-redis" version = "0.1.0" dependencies = [ + "async-trait", "event-bus-adapter", "futures 0.3.28", "futures-util", + "plugin-api", "redis-async", "serde", "thiserror", @@ -1707,6 +1967,14 @@ dependencies = [ [[package]] name = "file-storage-s3" version = "0.1.0" +dependencies = [ + "file-storage-adapter", + "futures 0.3.28", + "rust-s3", + "serde", + "tokio 1.28.2", + "tracing", +] [[package]] name = "filetime" @@ -2072,6 +2340,18 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "gumdrop" version = "0.8.1" @@ -2709,6 +2989,15 @@ dependencies = [ "winapi-build", ] +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + [[package]] name = "lang_provider" version = "0.1.0" @@ -2869,6 +3158,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if 1.0.0", + "value-bag", ] [[package]] @@ -2916,6 +3206,17 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" +[[package]] +name = "maybe-async" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f1b8c13cb1f814b634a96b2c725449fe7ed464a7b8781de8688be5ffbd3f305" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "maybe-owned" version = "0.3.4" @@ -2931,6 +3232,12 @@ dependencies = [ "digest", ] +[[package]] +name = "md5" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" + [[package]] name = "memchr" version = "2.5.0" @@ -2964,6 +3271,14 @@ dependencies = [ "autocfg 1.1.0", ] +[[package]] +name = "migration" +version = "0.1.0" +dependencies = [ + "async-std", + "sea-orm-migration", +] + [[package]] name = "mime" version = "0.3.17" @@ -2980,6 +3295,15 @@ dependencies = [ "unicase", ] +[[package]] +name = "minidom" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f45614075738ce1b77a1768912a60c0227525971b03e09122a05b8a34a2a6278" +dependencies = [ + "rxml", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -3296,6 +3620,45 @@ dependencies = [ "uuid 1.3.3", ] +[[package]] +name = "ordered-multimap" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" +dependencies = [ + "dlv-list", + "hashbrown 0.12.3", +] + +[[package]] +name = "os_str_bytes" +version = "6.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" + +[[package]] +name = "ouroboros" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1358bd1558bd2a083fed428ffeda486fbfb323e698cdda7794259d592ca72db" +dependencies = [ + "aliasable", + "ouroboros_macro", +] + +[[package]] +name = "ouroboros_macro" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f7d21ccd03305a674437ee1248f3ab5d4b1db095cf1caf49f1713ddf61956b7" +dependencies = [ + "Inflector", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "overload" version = "0.1.1" @@ -3392,7 +3755,7 @@ dependencies = [ "async-trait", "chrono", "config", - "futures 0.1.31", + "futures 0.3.28", "model", "serde", "thiserror", @@ -3428,6 +3791,7 @@ dependencies = [ "derive_more", "fulfillment_adapter", "payment-adapter", + "plugin-api", "serde", "thiserror", "tokio 1.28.2", @@ -3566,11 +3930,35 @@ version = "0.1.0" dependencies = [ "actix-web", "async-trait", + "bincode", + "cache-adapter", "config", + "derive_more", + "event-bus-adapter", + "file-storage-adapter", + "futures 0.3.28", + "payment-adapter", + "serde", "thiserror", "tracing", ] +[[package]] +name = "polling" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +dependencies = [ + "autocfg 1.1.0", + "bitflags", + "cfg-if 1.0.0", + "concurrent-queue", + "libc", + "log", + "pin-project-lite 0.2.9", + "windows-sys 0.48.0", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -3664,6 +4052,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "quick-xml" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "quote" version = "1.0.26" @@ -4108,10 +4506,12 @@ dependencies = [ "serde_urlencoded", "tokio 1.28.2", "tokio-native-tls", + "tokio-util 0.7.8", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-streams", "web-sys", "winreg 0.10.1", ] @@ -4201,6 +4601,49 @@ dependencies = [ "tokio-rustls", ] +[[package]] +name = "rust-ini" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" +dependencies = [ + "cfg-if 1.0.0", + "ordered-multimap", +] + +[[package]] +name = "rust-s3" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b2ac5ff6acfbe74226fa701b5ef793aaa054055c13ebb7060ad36942956e027" +dependencies = [ + "async-trait", + "aws-creds", + "aws-region", + "base64 0.13.1", + "bytes 1.4.0", + "cfg-if 1.0.0", + "futures 0.3.28", + "hex", + "hmac", + "http", + "log", + "maybe-async", + "md5", + "minidom", + "percent-encoding", + "quick-xml", + "reqwest 0.11.17", + "serde", + "serde_derive", + "sha2", + "thiserror", + "time 0.3.20", + "tokio 1.28.2", + "tokio-stream", + "url", +] + [[package]] name = "rust_decimal" version = "1.29.1" @@ -4322,6 +4765,23 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "rxml" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a98f186c7a2f3abbffb802984b7f1dfd65dac8be1aafdaabbca4137f53f0dff7" +dependencies = [ + "bytes 1.4.0", + "rxml_validation", + "smartstring", +] + +[[package]] +name = "rxml_validation" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22a197350ece202f19a166d1ad6d9d6de145e1d2a8ef47db299abe164dbd7530" + [[package]] name = "ryu" version = "1.0.13" @@ -4359,6 +4819,151 @@ dependencies = [ "untrusted", ] +[[package]] +name = "sea-orm" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fade86e8d41fd1a4721f84cb834f4ca2783f973cc30e6212b7fafc134f169214" +dependencies = [ + "async-stream", + "async-trait", + "futures 0.3.28", + "log", + "ouroboros", + "sea-orm-macros", + "sea-query", + "sea-query-binder", + "sea-strum", + "serde", + "sqlx", + "thiserror", + "tracing", + "url", +] + +[[package]] +name = "sea-orm-cli" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbf34a2caf70c2e3be9bb1e674e9540f6dfd7c8f40f6f05daf3b9740e476005" +dependencies = [ + "chrono", + "clap 3.2.25", + "dotenvy", + "regex", + "sea-schema", + "tracing", + "tracing-subscriber", + "url", +] + +[[package]] +name = "sea-orm-macros" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28936f26d62234ff0be16f80115dbdeb3237fe9c25cf18fbcd1e3b3592360f20" +dependencies = [ + "bae", + "heck 0.3.3", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "sea-orm-migration" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "278d3adfd0832b6ffc17d3cfbc574d3695a5c1b38814e0bc8ac238d33f3d87cf" +dependencies = [ + "async-trait", + "clap 3.2.25", + "dotenvy", + "futures 0.3.28", + "sea-orm", + "sea-orm-cli", + "sea-schema", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "sea-query" +version = "0.28.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbab99b8cd878ab7786157b7eb8df96333a6807cc6e45e8888c85b51534b401a" +dependencies = [ + "sea-query-derive", +] + +[[package]] +name = "sea-query-binder" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cea85029985b40dfbf18318d85fe985c04db7c1b4e5e8e0a0a0cdff5f1e30f9" +dependencies = [ + "sea-query", + "sqlx", +] + +[[package]] +name = "sea-query-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63f62030c60f3a691f5fe251713b4e220b306e50a71e1d6f9cce1f24bb781978" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 1.0.109", + "thiserror", +] + +[[package]] +name = "sea-schema" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeb2940bb5a10bc6cd05b450ce6cd3993e27fddd7eface2becb97fc5af3a040e" +dependencies = [ + "futures 0.3.28", + "sea-query", + "sea-schema-derive", +] + +[[package]] +name = "sea-schema-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56821b7076f5096b8f726e2791ad255a99c82498e08ec477a65a96c461ff1927" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "sea-strum" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391d06a6007842cfe79ac6f7f53911b76dfd69fc9a6769f1cf6569d12ce20e1b" +dependencies = [ + "sea-strum_macros", +] + +[[package]] +name = "sea-strum_macros" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69b4397b825df6ccf1e98bcdabef3bbcfc47ff5853983467850eeab878384f21" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + [[package]] name = "seahash" version = "4.1.0" @@ -4643,6 +5248,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg 1.1.0", + "static_assertions", + "version_check", +] + [[package]] name = "smol_str" version = "0.1.24" @@ -4880,7 +5496,7 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ - "clap", + "clap 2.34.0", "lazy_static", "structopt-derive", ] @@ -5061,6 +5677,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "textwrap" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" + [[package]] name = "thiserror" version = "1.0.40" @@ -5666,6 +6288,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "value-bag" +version = "1.0.0-alpha.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" +dependencies = [ + "ctor", + "version_check", +] + [[package]] name = "vcpkg" version = "0.2.15" @@ -5873,6 +6505,19 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-streams" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wasmparser" version = "0.93.0" diff --git a/Cargo.toml b/Cargo.toml index dbc9b98..9e71772 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,47 +9,56 @@ members = [ # actors "crates/account_manager", "crates/cart_manager", -# "crates/database_manager", + # "crates/database_manager", "crates/email_manager", "crates/order_manager", "crates/payment_manager", "crates/search_manager", "crates/stock_manager", "crates/token_manager", -# "crates/fs_manager", + # "crates/fs_manager", "crates/lang_provider", "crates/fulfillment_adapter", -# "crates/payment_adapter_pay_u", + # "crates/payment_adapter_pay_u", # artifacts -# "crates/db-seed", -# "crates/api", -# "crates/web", + # "crates/db-seed", + # "crates/api", + # "crates/web", # vendor -# "vendor/t_pay", -# "vendor/pay_u", + # "vendor/t_pay", + # "vendor/pay_u", # PLUGINS "crates/plugin-api", # PAYMENT "crates/payment-adapter", - "crates/payment-pay-u", - "crates/payment-stripe", + "crates/payment-pay-u-plugin", + "crates/payment-stripe-plugin", # EVENT BUS "crates/event-bus-messages", "crates/event-bus-adapter", - "crates/event-bus-redis", + "crates/event-bus-redis-plugin", # CACHE "crates/cache-adapter", - "crates/cache-adapter-redis", - "crates/cache-adapter-embedded-memory", + "crates/cache-redis-plugin", + "crates/cache-embedded-memory-plugin", # FILE STORAGE "crates/file-storage-adapter", - "crates/file-storage-local", - "crates/file-storage-s3", + "crates/file-storage-local-plugin", + "crates/file-storage-s3-plugin", + # database + "migration", ] exclude = [ "crates/web" ] +[workspace.dependencies] +plugin-api = { path = "crates/plugin-api" } +payment-adapter = { path = "crates/payment-adapter" } +event-bus-adapter = { path = "crates/event-bus-adapter" } +cache-adapter = { path = "crates/cache-adapter" } +file-storage-adapter = { path = "crates/file-storage-adapter" } + [profile.release] lto = true opt-level = 's' diff --git a/build.rs b/build.rs deleted file mode 100644 index 7609593..0000000 --- a/build.rs +++ /dev/null @@ -1,5 +0,0 @@ -// generated by `sqlx migrate build-script` -fn main() { - // trigger recompilation when a new migration is added - println!("cargo:rerun-if-changed=migrations"); -} \ No newline at end of file diff --git a/crates/cache-adapter/Cargo.toml b/crates/cache-adapter/Cargo.toml index 576aa2d..4cf4f36 100644 --- a/crates/cache-adapter/Cargo.toml +++ b/crates/cache-adapter/Cargo.toml @@ -5,7 +5,9 @@ edition = "2021" [dependencies] async-trait = { version = "0.1.68" } -serde = { version = "1.0.163", feeatures = ['derive'] } +bincode = { version = "1" } +config = { path = "../config" } +serde = { version = "1.0.163", features = ['derive'] } thiserror = { version = "1.0.40" } toml = { version = "0.7.3" } -config = { path = "../config" } +tracing = { version = "0.1.37" } diff --git a/crates/cache-adapter/src/lib.rs b/crates/cache-adapter/src/lib.rs index 9ba21cc..3696a56 100644 --- a/crates/cache-adapter/src/lib.rs +++ b/crates/cache-adapter/src/lib.rs @@ -1,7 +1,10 @@ +#![feature(box_into_inner)] + use std::borrow::Cow; use async_trait::async_trait; pub use config::PluginConfig; +use tracing::warn; #[derive(Debug, thiserror::Error)] pub enum Error { @@ -25,26 +28,41 @@ pub enum InvalidatePattern<'s> { Const(Cow<'s, str>), } -#[async_trait] -pub trait CacheAdapter: Sized { - async fn new(config: PluginConfig) -> CResult; +pub struct CacheObject(pub Option>); - async fn read(&mut self, key: &str) -> CResult> +impl CacheObject { + pub fn into_inner(self) -> CResult> where - T: serde::de::DeserializeOwned; + T: serde::de::DeserializeOwned, + { + let Some(data) = self.0 else { + return Ok(None) + }; + bincode::deserialize(&data) + .map_err(|e| { + warn!("Malformed cache entry: {e}"); + Error::InvalidEntry + }) + .map(Some) + } +} - async fn set( +#[async_trait] +pub trait CacheAdapter { + async fn new(config: PluginConfig) -> CResult + where + Self: Sized; + + async fn read(&self, key: &str) -> CResult; + + async fn set( &mut self, key: &str, - data: T, + data: &[u8], expires_in: Option, - ) -> CResult<()> - where - T: serde::Serialize + Send; + ) -> CResult<()>; async fn invalidate(&mut self, pattern: InvalidatePattern<'_>) -> CResult; async fn clear(&mut self) -> CResult; } - -pub struct CacheStorage {} diff --git a/crates/cache-adapter-embedded-memory/Cargo.toml b/crates/cache-embedded-memory-plugin/Cargo.toml similarity index 83% rename from crates/cache-adapter-embedded-memory/Cargo.toml rename to crates/cache-embedded-memory-plugin/Cargo.toml index 9c43e71..a501072 100644 --- a/crates/cache-adapter-embedded-memory/Cargo.toml +++ b/crates/cache-embedded-memory-plugin/Cargo.toml @@ -3,12 +3,17 @@ name = "cache-adapter-embedded-memory" version = "0.1.0" edition = "2021" +[lib] +crate-type = ["cdylib"] +path = "src/lib.rs" + [dependencies] -cache-adapter = { path = "../cache-adapter" } -serde = { version = "1.0.163", features = ['derive'] } async-trait = { version = "0.1.68" } -chrono = { version = "0.4.26" } bincode = { version = "1" } -tracing = { version = "0" } +cache-adapter = { path = "../cache-adapter" } +chrono = { version = "0.4.26" } futures-executor = { version = "0.3.28", features = [] } +plugin-api = { workspace = true } +serde = { version = "1.0.163", features = ['derive'] } tokio = { version = "1.28.2", features = ['full'] } +tracing = { version = "0" } diff --git a/crates/cache-adapter-embedded-memory/src/lib.rs b/crates/cache-embedded-memory-plugin/src/lib.rs similarity index 69% rename from crates/cache-adapter-embedded-memory/src/lib.rs rename to crates/cache-embedded-memory-plugin/src/lib.rs index f11d383..6ea0e94 100644 --- a/crates/cache-adapter-embedded-memory/src/lib.rs +++ b/crates/cache-embedded-memory-plugin/src/lib.rs @@ -3,10 +3,10 @@ use std::sync::{Arc, RwLock}; use std::time::Duration; use async_trait::async_trait; -use cache_adapter::{CResult, CacheAdapter, Error, InvalidatePattern, PluginConfig}; -use serde::de::DeserializeOwned; +use cache_adapter::{CResult, CacheAdapter, CacheObject, Error, InvalidatePattern, PluginConfig}; +use plugin_api::{AppConfig, Cache, PluginType}; use serde::{Deserialize, Serialize}; -use tracing::error; +use tracing::{error, warn}; pub struct CacheEntry { pub expires_at: Option, @@ -37,14 +37,11 @@ impl CacheAdapter for EmbeddedMemoryCacheAdapter { }) } - async fn read(&mut self, key: &str) -> CResult> - where - T: DeserializeOwned, - { + async fn read(&self, key: &str) -> CResult { let (valid, data) = { let lock = self.storage.read().unwrap(); let entry = match lock.get(key) { - None => return Ok(None), + None => return Ok(CacheObject(None)), Some(entry) => entry, }; let valid = entry @@ -52,30 +49,21 @@ impl CacheAdapter for EmbeddedMemoryCacheAdapter { .map(|exp| exp >= chrono::Utc::now().naive_utc()) .unwrap_or(true); let data = if valid { - match bincode::deserialize::(&entry.payload) { - Ok(t) => Some(t), - Err(e) => { - tracing::warn!("Malformed embedded cache entry {key:?}: {e}"); - return Err(Error::InvalidEntry); - } - } + Some(entry.payload.clone()) } else { None }; (valid, data) }; if valid { - Ok(data) + Ok(CacheObject(data)) } else { self.storage.write().unwrap().remove(key); - Ok(None) + Ok(CacheObject(None)) } } - async fn set(&mut self, key: &str, data: T, expires_in: Option) -> CResult<()> - where - T: Serialize + Send, - { + async fn set(&mut self, key: &str, data: &[u8], expires_in: Option) -> CResult<()> { let expires_at = if let Some(duration) = expires_in.or(self.ttl) { let storage = self.storage.clone(); let exp = @@ -96,10 +84,7 @@ impl CacheAdapter for EmbeddedMemoryCacheAdapter { key.into(), CacheEntry { expires_at, - payload: bincode::serialize(&data).map_err(|e| { - tracing::warn!("Malformed embedded cache entry {key:?}: {e}"); - Error::InvalidEntry - })?, + payload: data.to_owned(), }, ); Ok(()) @@ -144,3 +129,47 @@ impl<'s> MatchesKey for InvalidatePattern<'s> { } } } + +pub struct Plugin { + config: Option, +} + +static PLUGIN_NAME: &str = "cache-embedded-memory"; + +#[async_trait] +impl plugin_api::Plugin for Plugin { + fn plugin_type() -> PluginType + where + Self: Sized, + { + PluginType::Cache + } + + fn name(&self) -> &'static str { + PLUGIN_NAME + } + + async fn initialize(app_config: &AppConfig) -> Self + where + Self: Sized, + { + Self { + config: app_config.plugin_config(PLUGIN_NAME), + } + } + + async fn register_cache(&mut self, cache: &'static mut Cache) { + let Some(config) = self.config.as_ref() else { + warn!("Plugin {:?} does not have config", PLUGIN_NAME); + return; + }; + let adapter = match EmbeddedMemoryCacheAdapter::new(config.clone()).await { + Ok(adapter) => adapter, + Err(e) => { + warn!("Failed to construct adapter: {e}"); + return; + } + }; + cache.register(Box::new(adapter)); + } +} diff --git a/crates/cache-adapter-redis/Cargo.toml b/crates/cache-redis-plugin/Cargo.toml similarity index 91% rename from crates/cache-adapter-redis/Cargo.toml rename to crates/cache-redis-plugin/Cargo.toml index 83af443..3a07473 100644 --- a/crates/cache-adapter-redis/Cargo.toml +++ b/crates/cache-redis-plugin/Cargo.toml @@ -3,15 +3,19 @@ name = "cache-adapter-redis" version = "0.1.0" edition = "2021" +[lib] +crate-type = ["cdylib"] +path = "src/lib.rs" + [dependencies] -redis-async-pool = { git = "https://github.com/Eraden/redis-async-pool.git", branch = "upgrade-dependencies" } -cache-adapter = { path = "../cache-adapter" } -serde = { version = "1.0.163", features = ['derive'] } async-trait = { version = "0.1.68" } -chrono = { version = "0.4.26" } bincode = { version = "1" } -tracing = { version = "0" } -tokio = { version = "1.28.2", features = ['full'] } -redis = { version = "0.23.0" } +cache-adapter = { path = "../cache-adapter" } +chrono = { version = "0.4.26" } deadpool = { version = "0.9.5" } futures = { version = "0.3.28" } +redis = { version = "0.23.0" } +redis-async-pool = { git = "https://github.com/Eraden/redis-async-pool.git", branch = "upgrade-dependencies" } +serde = { version = "1.0.163", features = ['derive'] } +tokio = { version = "1.28.2", features = ['full'] } +tracing = { version = "0" } diff --git a/crates/cache-adapter-redis/src/lib.rs b/crates/cache-redis-plugin/src/lib.rs similarity index 85% rename from crates/cache-adapter-redis/src/lib.rs rename to crates/cache-redis-plugin/src/lib.rs index 536b1b2..3df73f3 100644 --- a/crates/cache-adapter-redis/src/lib.rs +++ b/crates/cache-redis-plugin/src/lib.rs @@ -1,10 +1,9 @@ use std::time::Duration; use async_trait::async_trait; -use cache_adapter::{CResult, CacheAdapter, Error, InvalidatePattern, PluginConfig}; +use cache_adapter::{CResult, CacheAdapter, CacheObject, Error, InvalidatePattern, PluginConfig}; use redis::AsyncCommands; use redis_async_pool::*; -use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use tracing::{error, warn}; @@ -60,10 +59,7 @@ impl CacheAdapter for RedisCacheAdapter { .await } - async fn read(&mut self, key: &str) -> CResult> - where - T: DeserializeOwned, - { + async fn read(&self, key: &str) -> CResult { let mut conn = self.client.get().await.map_err(|e| { error!("Failed to use pool connection to redis: {e}"); Error::Connect @@ -74,31 +70,20 @@ impl CacheAdapter for RedisCacheAdapter { Error::Connect })?; if !exists { - return Ok(None); + return Ok(CacheObject(None)); } let data: Vec = conn.get(&key).await.map_err(|e| { warn!("Failed to fetch {key:?} from redis: {e}"); Error::Connect })?; - let entry: T = bincode::deserialize(&data).map_err(|e| { - warn!("Malformed redis cache entry {key:?}: {e}"); - Error::InvalidEntry - })?; - Ok(Some(entry)) + Ok(CacheObject(Some(data))) } - async fn set(&mut self, key: &str, data: T, expires_in: Option) -> CResult<()> - where - T: Serialize + Send, - { + async fn set(&mut self, key: &str, data: &[u8], expires_in: Option) -> CResult<()> { let mut conn = self.client.get().await.map_err(|e| { error!("Failed to use pool connection to redis: {e}"); Error::Connect })?; - let data = bincode::serialize(&data).map_err(|e| { - warn!("Malformed redis cache entry {key:?}: {e}"); - Error::InvalidEntry - })?; let key = self.format_key(&*key); match expires_in { Some(duration) => { diff --git a/crates/channels/Cargo.toml b/crates/channels/Cargo.toml index 60443f7..0f4ae68 100644 --- a/crates/channels/Cargo.toml +++ b/crates/channels/Cargo.toml @@ -28,5 +28,5 @@ tarpc = { version = "0", features = ["tokio1", "serde-transport-bincode", "serde thiserror = { version = "1" } tokio = { version = "1", features = ['full'] } tracing = { version = "0" } -whatlang = { version = "0" } uuid = { version = "1", features = ['v4'] } +whatlang = { version = "0" } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 9c80f89..f0c43e6 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -686,6 +686,7 @@ pub struct AppConfig { tokens: TokensConfig, #[serde(default)] web: WebConfig, + plugin: HashMap, } impl Example for AppConfig { @@ -704,6 +705,7 @@ impl Example for AppConfig { order_manager: OrderConfig::example(), config_path: "".to_string(), tokens: TokensConfig::example(), + plugin: Default::default(), } } } @@ -772,6 +774,10 @@ impl AppConfig { pub fn web_mut(&mut self) -> &mut WebConfig { &mut self.web } + + pub fn plugin_config(&self, name: &str) -> Option { + self.plugin.get(name).cloned().map(PluginConfig) + } } impl Default for AppConfig { @@ -790,6 +796,7 @@ impl Default for AppConfig { order_manager: OrderConfig::default(), config_path: "".to_string(), tokens: Default::default(), + plugin: Default::default(), } } } @@ -876,12 +883,17 @@ pub fn init_tracing(_service_name: &str) { .unwrap(); } -pub struct PluginConfig(pub String); +#[derive(Clone)] +pub struct PluginConfig(pub toml::Value); -impl PluginConfig { - pub fn config( - &self, - ) -> std::result::Result { - toml::from_str(&self.0) +impl Default for PluginConfig { + fn default() -> Self { + Self(toml::Value::Table(toml::Table::default())) + } +} + +impl PluginConfig { + pub fn config(self) -> std::result::Result { + self.0.try_into::() } } diff --git a/crates/event-bus-adapter/Cargo.toml b/crates/event-bus-adapter/Cargo.toml index 9be2108..0cd60e6 100644 --- a/crates/event-bus-adapter/Cargo.toml +++ b/crates/event-bus-adapter/Cargo.toml @@ -4,10 +4,13 @@ version = "0.1.0" edition = "2021" [dependencies] -serde = { version = "1.0.162", features = ['derive'] } bincode = { version = "1.3.3" } -thiserror = { version = "1.0.40" } +config = { path = "../config" } event-bus-messages = { path = "../event-bus-messages" } futures = { version = "0.3.28" } +serde = { version = "1.0.162", features = ['derive'] } +thiserror = { version = "1.0.40" } toml = { version = "0.7.3" } -config = { path = "../config" } +uuid = { version = "1.3.3", features = ['v4'] } +async-trait = { version = "0.1.68" } +tokio = { version = "1.28.2", features = ['full'] } diff --git a/crates/event-bus-adapter/src/lib.rs b/crates/event-bus-adapter/src/lib.rs index f74fa7f..c3ea2e0 100644 --- a/crates/event-bus-adapter/src/lib.rs +++ b/crates/event-bus-adapter/src/lib.rs @@ -1,7 +1,14 @@ #![feature(async_fn_in_trait)] +#![feature(box_into_inner)] +use std::collections::HashMap; +use std::pin::Pin; +use std::sync::{Arc, RwLock}; + +use async_trait::async_trait; pub use config::PluginConfig; pub use event_bus_messages::*; +use uuid::Uuid; #[derive(Debug, thiserror::Error)] pub enum EBError { @@ -15,16 +22,86 @@ pub enum EBError { pub type EBResult = Result; -pub trait MessageSend { +#[async_trait] +pub trait MessageSend: Send + Sync + 'static { async fn send(&mut self, topic: Topic, msg: Msg) -> EBResult<()>; } -pub trait EventBus -where - Stream: futures::stream::Stream, - Sender: MessageSend, -{ - async fn connect(config: PluginConfig) -> Result<(Stream, Sender), ()>; +#[async_trait] +pub trait Subscriber: Send { + fn handle(&self, msg: &Message); + + fn matches(&self, msg: &Message) -> bool; +} + +#[derive(Copy, Clone)] +pub struct UnSubscribe(Uuid); + +pub struct EventBus { + sender: Box, + subscribers: Arc>>>, + is_alive: Arc>, +} + +impl EventBus { + pub fn new( + stream: Box + Send + Sync + Unpin + 'static>, + sender: Box, + ) -> Self { + let subscribers: Arc>>> = + Arc::new(Default::default()); + let is_alive = Arc::new(RwLock::new(true)); + + { + let subscribers = subscribers.clone(); + let is_alive = is_alive.clone(); + tokio::spawn(async move { + let mut stream = Pin::new(stream); + let mut stream = stream.as_mut(); + loop { + use futures::StreamExt; + + if !*is_alive.read().unwrap() { + break; + } + let Some(msg) = stream.next().await else { + break; + }; + for subscriber in subscribers.read().unwrap().values() { + let subscriber = subscriber.as_ref(); + if !subscriber.matches(&msg) { + continue; + } + subscriber.handle(&msg); + } + } + }); + } + + Self { + sender, + subscribers, + is_alive, + } + } + + async fn emit(&mut self, data: Msg) -> EBResult<()> { + let sender = self.sender.as_mut(); + sender.send(Topic::Default, data).await + } + + async fn subscribe( + &mut self, + subscriber: Box, + ) -> UnSubscribe { + let id = Uuid::new_v4(); + self.subscribers.write().unwrap().insert(id, subscriber); + UnSubscribe(id) + } + + async fn unsubscribe(&mut self, id: UnSubscribe) { + self.subscribers.write().unwrap().remove(&id.0); + } } /// For client-server purpose only @@ -43,3 +120,6 @@ impl ClientMsg { bincode::serialize(self) } } + +#[cfg(test)] +mod tests {} diff --git a/crates/event-bus-messages/Cargo.toml b/crates/event-bus-messages/Cargo.toml index 960c40d..f04ed98 100644 --- a/crates/event-bus-messages/Cargo.toml +++ b/crates/event-bus-messages/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -thiserror = { version = "1.0.40" } -serde = { version = "1.0.162", features = ['derive'] } bincode = { version = "1.3.3" } +serde = { version = "1.0.162", features = ['derive'] } serde_json = { version = "1.0.96" } +thiserror = { version = "1.0.40" } diff --git a/crates/event-bus-redis/Cargo.toml b/crates/event-bus-redis-plugin/Cargo.toml similarity index 66% rename from crates/event-bus-redis/Cargo.toml rename to crates/event-bus-redis-plugin/Cargo.toml index 0f0c0a9..d1e9e65 100644 --- a/crates/event-bus-redis/Cargo.toml +++ b/crates/event-bus-redis-plugin/Cargo.toml @@ -3,12 +3,18 @@ name = "event-bus-redis" version = "0.1.0" edition = "2021" +[lib] +crate-type = ["cdylib"] +path = "src/lib.rs" + [dependencies] -redis-async = { version = "0.16.0" } -event-bus-adapter = { path = "../event-bus-adapter" } -thiserror = { version = "1.0.40" } -futures-util = { version = "0.3.28" } +event-bus-adapter = { workspace = true } +plugin-api = { workspace = true } futures = { version = "0.3.28" } -tracing = { version = "0" } +futures-util = { version = "0.3.28" } +redis-async = { version = "0.16.0" } serde = { version = "1.0.162" } +thiserror = { version = "1.0.40" } toml = { version = "0.7.4" } +tracing = { version = "0" } +async-trait = { version = "0.1.68" } diff --git a/crates/event-bus-redis/src/lib.rs b/crates/event-bus-redis-plugin/src/lib.rs similarity index 71% rename from crates/event-bus-redis/src/lib.rs rename to crates/event-bus-redis-plugin/src/lib.rs index 11c98b5..d61696b 100644 --- a/crates/event-bus-redis/src/lib.rs +++ b/crates/event-bus-redis-plugin/src/lib.rs @@ -3,11 +3,13 @@ use std::pin::Pin; use std::task::{Context, Poll}; +use async_trait::async_trait; use event_bus_adapter::{ EBError, EBResult, EventBus, Message, MessageSend, Msg, PluginConfig, Topic, }; use futures_util::stream::{SplitSink, SplitStream}; use futures_util::{SinkExt, StreamExt}; +use plugin_api::{AppConfig, EventBusRegister, PluginType}; use redis_async::client::connect::RespConnection; use redis_async::resp::RespValue; use redis_async::resp::RespValue::BulkString; @@ -15,6 +17,7 @@ use tracing::warn; pub struct MessageSender(SplitSink); +#[async_trait] impl MessageSend for MessageSender { async fn send(&mut self, topic: Topic, msg: Msg) -> EBResult<()> { match (Message { @@ -84,14 +87,53 @@ pub struct RedisEventBusConfig { pub struct RedisEventBus; -impl EventBus for RedisEventBus { - async fn connect(config: PluginConfig) -> Result<(MessageStream, MessageSender), ()> { +impl RedisEventBus { + async fn connect(config: PluginConfig) -> Result<(Box, Box), ()> { let RedisEventBusConfig { host, port } = config.config().expect("Invalid redis bus config"); let client = redis_async::client::connect(&host, port) .await .expect("Failed to connect to redis event bus"); let (sink, stream) = client.split(); - Ok((MessageStream(stream), MessageSender(sink))) + Ok(( + Box::new(MessageStream(stream)), + Box::new(MessageSender(sink)), + )) + } +} + +pub static PLUGIN_NAME: &str = "event-bus-redis"; + +pub struct RedisEventBusPlugin { + plugin_config: PluginConfig, +} + +#[async_trait] +impl plugin_api::Plugin for RedisEventBusPlugin { + fn plugin_type() -> PluginType + where + Self: Sized, + { + PluginType::EventBus + } + + fn name(&self) -> &'static str { + PLUGIN_NAME + } + + async fn initialize(app_config: &AppConfig) -> Self + where + Self: Sized, + { + Self { + plugin_config: app_config.plugin_config(PLUGIN_NAME).unwrap_or_default(), + } + } + + async fn register_event_bus(&mut self, register: &'static mut EventBusRegister) { + let Ok((stream, sender)) = RedisEventBus::connect(self.plugin_config.clone()).await else { + return + }; + register.register(PLUGIN_NAME, EventBus::new(stream, sender)); } } diff --git a/crates/file-storage-adapter/Cargo.toml b/crates/file-storage-adapter/Cargo.toml index 66c4055..70fdb0a 100644 --- a/crates/file-storage-adapter/Cargo.toml +++ b/crates/file-storage-adapter/Cargo.toml @@ -4,9 +4,9 @@ version = "0.1.0" edition = "2021" [dependencies] -thiserror = { version = "1.0.40" } async-trait = { version = "0.1.68" } -tracing = { version = "0.1.37" } config = { path = "../config" } futures = { version = "0.3.28", features = ["async-await", 'io-compat'] } futures-util = { version = "0.3.28" } +thiserror = { version = "1.0.40" } +tracing = { version = "0.1.37" } diff --git a/crates/file-storage-adapter/src/lib.rs b/crates/file-storage-adapter/src/lib.rs index 7608e7b..67f66e9 100644 --- a/crates/file-storage-adapter/src/lib.rs +++ b/crates/file-storage-adapter/src/lib.rs @@ -33,12 +33,16 @@ impl Display for Url { } #[async_trait] -pub trait FileStorage: Sized { - fn name() -> &'static str; +pub trait FileStorage { + fn name() -> &'static str + where + Self: Sized; - async fn new(config: &PluginConfig) -> SResult; + async fn new(config: PluginConfig) -> SResult + where + Self: Sized; - async fn store(&mut self, file: impl futures::AsyncRead + Unpin + Send) -> SResult; + async fn store(&mut self, file: Box) -> SResult; async fn erase(&mut self, file_name: Url) -> SResult; } diff --git a/crates/file-storage-local/Cargo.toml b/crates/file-storage-local-plugin/Cargo.toml similarity index 88% rename from crates/file-storage-local/Cargo.toml rename to crates/file-storage-local-plugin/Cargo.toml index 9bf384e..5c8a565 100644 --- a/crates/file-storage-local/Cargo.toml +++ b/crates/file-storage-local-plugin/Cargo.toml @@ -3,11 +3,15 @@ name = "file-storage-local" version = "0.1.0" edition = "2021" +[lib] +crate-type = ["cdylib"] +path = "src/lib.rs" + [dependencies] -file-storage-adapter = { path = "../file-storage-adapter" } -tokio = { version = "1.28.2", features = ['full'] } -futures = { version = "0.3.28" } async-trait = { version = "0.1.68" } +file-storage-adapter = { path = "../file-storage-adapter" } +futures = { version = "0.3.28" } serde = { version = "1.0.163", features = ['derive'] } -uuid = { version = "1.3.3", features = ['v4'] } +tokio = { version = "1.28.2", features = ['full'] } tracing = { version = "0.1" } +uuid = { version = "1.3.3", features = ['v4'] } diff --git a/crates/file-storage-local/src/lib.rs b/crates/file-storage-local-plugin/src/lib.rs similarity index 92% rename from crates/file-storage-local/src/lib.rs rename to crates/file-storage-local-plugin/src/lib.rs index 273e813..628d54c 100644 --- a/crates/file-storage-local/src/lib.rs +++ b/crates/file-storage-local-plugin/src/lib.rs @@ -25,7 +25,7 @@ impl FileStorage for FileStorageLocal { "file-storage-local" } - async fn new(config: &PluginConfig) -> SResult { + async fn new(config: PluginConfig) -> SResult { Ok(Self { config: Arc::new(RwLock::new(config.config().map_err(|e| { error!("Invalid config for local file storage: {e}"); @@ -34,7 +34,7 @@ impl FileStorage for FileStorageLocal { }) } - async fn store(&mut self, mut input_stream: impl AsyncRead + Unpin + Send) -> SResult { + async fn store(&mut self, mut input_stream: Box) -> SResult { let (root, base_url) = { let config = self.config.read().unwrap(); let root = config.root.clone(); diff --git a/crates/file-storage-s3-plugin/Cargo.toml b/crates/file-storage-s3-plugin/Cargo.toml new file mode 100644 index 0000000..dadce52 --- /dev/null +++ b/crates/file-storage-s3-plugin/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "file-storage-s3" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] +path = "src/lib.rs" + +[dependencies] +file-storage-adapter = { workspace = true } +futures = { version = "0.3.28" } +rust-s3 = { version = "0.33.0", features = [] } +serde = { version = "1.0.163", features = ['derive'] } +tokio = { version = "1.28.2" } +tracing = { version = "0.1.37" } diff --git a/crates/file-storage-s3/src/lib.rs b/crates/file-storage-s3-plugin/src/lib.rs similarity index 100% rename from crates/file-storage-s3/src/lib.rs rename to crates/file-storage-s3-plugin/src/lib.rs diff --git a/crates/file-storage-s3/Cargo.toml b/crates/file-storage-s3/Cargo.toml deleted file mode 100644 index 76fdd10..0000000 --- a/crates/file-storage-s3/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "file-storage-s3" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/crates/fulfillment_adapter/Cargo.toml b/crates/fulfillment_adapter/Cargo.toml index 8d52c21..4e37bd1 100644 --- a/crates/fulfillment_adapter/Cargo.toml +++ b/crates/fulfillment_adapter/Cargo.toml @@ -4,6 +4,6 @@ version = "0.1.0" edition = "2021" [dependencies] -tracing = { version = "0" } -thiserror = { version = "1.0.40" } async-trait = { version = "0.1.68" } +thiserror = { version = "1.0.40" } +tracing = { version = "0" } diff --git a/crates/model/Cargo.toml b/crates/model/Cargo.toml index ef0bfaa..e6b4b00 100644 --- a/crates/model/Cargo.toml +++ b/crates/model/Cargo.toml @@ -28,6 +28,6 @@ serde = { version = "1" } sqlx = { version = "0", features = ["migrate", "runtime-actix-rustls", "all-types", "postgres"], optional = true } sqlx-core = { version = "0", features = [], optional = true } thiserror = { version = "1" } +tracing = { version = "0.1.37" } uuid = { version = "1", features = ["serde"] } validator = { version = "0" } -tracing = { version = "0.1.37" } diff --git a/crates/model/src/lib.rs b/crates/model/src/lib.rs index 3e78701..d3e3bf7 100644 --- a/crates/model/src/lib.rs +++ b/crates/model/src/lib.rs @@ -4,6 +4,7 @@ pub mod api; pub mod encrypt; pub mod v3; +pub mod v4; use std::fmt::{Display, Formatter}; use std::ops; diff --git a/crates/model/src/v4/addresses.rs b/crates/model/src/v4/addresses.rs new file mode 100644 index 0000000..ac5edb3 --- /dev/null +++ b/crates/model/src/v4/addresses.rs @@ -0,0 +1,140 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "addresses" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub customer_id: Option, + pub company: Option, + pub first_name: Option, + pub last_name: Option, + pub address_1: Option, + pub address_2: Option, + pub city: Option, + pub country_code: Option, + pub province: Option, + pub postal_code: Option, + pub phone: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + CustomerId, + Company, + FirstName, + LastName, + Address1, + Address2, + City, + CountryCode, + Province, + PostalCode, + Phone, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + ClaimOrders, + Countries, + Customers, + Swaps, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::CustomerId => ColumnType::String(None).def().null(), + Self::Company => ColumnType::String(None).def().null(), + Self::FirstName => ColumnType::String(None).def().null(), + Self::LastName => ColumnType::String(None).def().null(), + Self::Address1 => ColumnType::String(None).def().null(), + Self::Address2 => ColumnType::String(None).def().null(), + Self::City => ColumnType::String(None).def().null(), + Self::CountryCode => ColumnType::String(None).def().null(), + Self::Province => ColumnType::String(None).def().null(), + Self::PostalCode => ColumnType::String(None).def().null(), + Self::Phone => ColumnType::String(None).def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::ClaimOrders => Entity::has_many(super::claim_orders::Entity).into(), + Self::Countries => Entity::belongs_to(super::countries::Entity) + .from(Column::CountryCode) + .to(super::countries::Column::Iso2) + .into(), + Self::Customers => Entity::belongs_to(super::customers::Entity) + .from(Column::CustomerId) + .to(super::customers::Column::Id) + .into(), + Self::Swaps => Entity::has_many(super::swaps::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ClaimOrders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Countries.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Customers.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Swaps.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/analytics_configs.rs b/crates/model/src/v4/analytics_configs.rs new file mode 100644 index 0000000..9adc850 --- /dev/null +++ b/crates/model/src/v4/analytics_configs.rs @@ -0,0 +1,73 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "analytics_configs" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub user_id: String, + pub opt_out: bool, + pub anonymize: bool, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + CreatedAt, + UpdatedAt, + DeletedAt, + UserId, + OptOut, + Anonymize, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::UserId => ColumnType::String(None).def(), + Self::OptOut => ColumnType::Boolean.def(), + Self::Anonymize => ColumnType::Boolean.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/batch_jobs.rs b/crates/model/src/v4/batch_jobs.rs new file mode 100644 index 0000000..faad315 --- /dev/null +++ b/crates/model/src/v4/batch_jobs.rs @@ -0,0 +1,110 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "batch_jobs" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub r#type: String, + pub created_by: Option, + pub context: Option, + pub result: Option, + pub dry_run: bool, + pub created_at: DateTimeWithTimeZone, + pub pre_processed_at: Option, + pub confirmed_at: Option, + pub processing_at: Option, + pub completed_at: Option, + pub failed_at: Option, + pub canceled_at: Option, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Type, + CreatedBy, + Context, + Result, + DryRun, + CreatedAt, + PreProcessedAt, + ConfirmedAt, + ProcessingAt, + CompletedAt, + FailedAt, + CanceledAt, + UpdatedAt, + DeletedAt, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Users, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Type => ColumnType::Text.def(), + Self::CreatedBy => ColumnType::String(None).def().null(), + Self::Context => ColumnType::JsonBinary.def().null(), + Self::Result => ColumnType::JsonBinary.def().null(), + Self::DryRun => ColumnType::Boolean.def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::PreProcessedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::ConfirmedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::ProcessingAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CompletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::FailedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CanceledAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Users => Entity::belongs_to(super::users::Entity) + .from(Column::CreatedBy) + .to(super::users::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Users.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/cart.rs b/crates/model/src/v4/cart.rs new file mode 100644 index 0000000..536767b --- /dev/null +++ b/crates/model/src/v4/cart.rs @@ -0,0 +1,199 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::CartTypes; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "cart" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub email: Option, + pub billing_address_id: Option, + pub shipping_address_id: Option, + pub region_id: String, + pub customer_id: Option, + pub payment_id: Option, + pub r#type: CartTypes, + pub completed_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, + pub idempotency_key: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Email, + BillingAddressId, + ShippingAddressId, + RegionId, + CustomerId, + PaymentId, + Type, + CompletedAt, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, + IdempotencyKey, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Addresses2, + Addresses1, + Customers, + LineItems, + Order, + PaymentSessions, + Payments, + Regions, + ShippingMethods, + Swap, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Email => ColumnType::String(None).def().null(), + Self::BillingAddressId => ColumnType::String(None).def().null(), + Self::ShippingAddressId => ColumnType::String(None).def().null(), + Self::RegionId => ColumnType::String(None).def(), + Self::CustomerId => ColumnType::String(None).def().null(), + Self::PaymentId => ColumnType::String(None).def().null().unique(), + Self::Type => CartTypes::db_type().def(), + Self::CompletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::IdempotencyKey => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Addresses2 => Entity::belongs_to(super::addresses::Entity) + .from(Column::BillingAddressId) + .to(super::addresses::Column::Id) + .into(), + Self::Addresses1 => Entity::belongs_to(super::addresses::Entity) + .from(Column::ShippingAddressId) + .to(super::addresses::Column::Id) + .into(), + Self::Customers => Entity::belongs_to(super::customers::Entity) + .from(Column::CustomerId) + .to(super::customers::Column::Id) + .into(), + Self::LineItems => Entity::has_many(super::line_items::Entity).into(), + Self::Order => Entity::has_one(super::order::Entity).into(), + Self::PaymentSessions => Entity::has_many(super::payment_sessions::Entity).into(), + Self::Payments => Entity::belongs_to(super::payments::Entity) + .from(Column::PaymentId) + .to(super::payments::Column::Id) + .into(), + Self::Regions => Entity::belongs_to(super::regions::Entity) + .from(Column::RegionId) + .to(super::regions::Column::Id) + .into(), + Self::ShippingMethods => Entity::has_many(super::shipping_methods::Entity).into(), + Self::Swap => Entity::has_one(super::swap::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Customers.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Order.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PaymentSessions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Payments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Regions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ShippingMethods.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Swap.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cart_discounts::Relation::Discounts.def() + } + fn via() -> Option { + Some(super::cart_discounts::Relation::Cart.def().rev()) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cart_gift_cards::Relation::GiftCards.def() + } + fn via() -> Option { + Some(super::cart_gift_cards::Relation::Cart.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/cart_discounts.rs b/crates/model/src/v4/cart_discounts.rs new file mode 100644 index 0000000..18832d9 --- /dev/null +++ b/crates/model/src/v4/cart_discounts.rs @@ -0,0 +1,83 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "cart_discounts" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub cart_id: String, + pub discount_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + CartId, + DiscountId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + CartId, + DiscountId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Carts, + Discounts, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::CartId => ColumnType::String(None).def(), + Self::DiscountId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Carts => Entity::belongs_to(super::carts::Entity) + .from(Column::CartId) + .to(super::carts::Column::Id) + .into(), + Self::Discounts => Entity::belongs_to(super::discounts::Entity) + .from(Column::DiscountId) + .to(super::discounts::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Carts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Discounts.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/cart_gift_cards.rs b/crates/model/src/v4/cart_gift_cards.rs new file mode 100644 index 0000000..d489426 --- /dev/null +++ b/crates/model/src/v4/cart_gift_cards.rs @@ -0,0 +1,83 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "cart_gift_cards" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub cart_id: String, + pub gift_card_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + CartId, + GiftCardId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + CartId, + GiftCardId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Carts, + GiftCards, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::CartId => ColumnType::String(None).def(), + Self::GiftCardId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Carts => Entity::belongs_to(super::carts::Entity) + .from(Column::CartId) + .to(super::carts::Column::Id) + .into(), + Self::GiftCards => Entity::belongs_to(super::gift_cards::Entity) + .from(Column::GiftCardId) + .to(super::gift_cards::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Carts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::GiftCards.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/carts.rs b/crates/model/src/v4/carts.rs new file mode 100644 index 0000000..e90b6e6 --- /dev/null +++ b/crates/model/src/v4/carts.rs @@ -0,0 +1,237 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::CartTypes; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "carts" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub email: Option, + pub billing_address_id: Option, + pub shipping_address_id: Option, + pub region_id: String, + pub customer_id: Option, + pub payment_id: Option, + pub r#type: CartTypes, + pub completed_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, + pub idempotency_key: Option, + pub context: Option, + pub payment_authorized_at: Option, + pub sales_channel_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Email, + BillingAddressId, + ShippingAddressId, + RegionId, + CustomerId, + PaymentId, + Type, + CompletedAt, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, + IdempotencyKey, + Context, + PaymentAuthorizedAt, + SalesChannelId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Addresses2, + Addresses1, + CustomShippingOptions, + Customers, + DraftOrders, + LineItems, + Orders, + PaymentSessions, + Payments, + Regions, + SalesChannels, + ShippingMethods, + Swaps, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Email => ColumnType::String(None).def().null(), + Self::BillingAddressId => ColumnType::String(None).def().null(), + Self::ShippingAddressId => ColumnType::String(None).def().null(), + Self::RegionId => ColumnType::String(None).def(), + Self::CustomerId => ColumnType::String(None).def().null(), + Self::PaymentId => ColumnType::String(None).def().null().unique(), + Self::Type => CartTypes::db_type().def(), + Self::CompletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::IdempotencyKey => ColumnType::String(None).def().null(), + Self::Context => ColumnType::JsonBinary.def().null(), + Self::PaymentAuthorizedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::SalesChannelId => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Addresses2 => Entity::belongs_to(super::addresses::Entity) + .from(Column::BillingAddressId) + .to(super::addresses::Column::Id) + .into(), + Self::Addresses1 => Entity::belongs_to(super::addresses::Entity) + .from(Column::ShippingAddressId) + .to(super::addresses::Column::Id) + .into(), + Self::CustomShippingOptions => { + Entity::has_many(super::custom_shipping_options::Entity).into() + } + Self::Customers => Entity::belongs_to(super::customers::Entity) + .from(Column::CustomerId) + .to(super::customers::Column::Id) + .into(), + Self::DraftOrders => Entity::has_one(super::draft_orders::Entity).into(), + Self::LineItems => Entity::has_many(super::line_items::Entity).into(), + Self::Orders => Entity::has_one(super::orders::Entity).into(), + Self::PaymentSessions => Entity::has_many(super::payment_sessions::Entity).into(), + Self::Payments => Entity::belongs_to(super::payments::Entity) + .from(Column::PaymentId) + .to(super::payments::Column::Id) + .into(), + Self::Regions => Entity::belongs_to(super::regions::Entity) + .from(Column::RegionId) + .to(super::regions::Column::Id) + .into(), + Self::SalesChannels => Entity::belongs_to(super::sales_channels::Entity) + .from(Column::SalesChannelId) + .to(super::sales_channels::Column::Id) + .into(), + Self::ShippingMethods => Entity::has_many(super::shipping_methods::Entity).into(), + Self::Swaps => Entity::has_one(super::swaps::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::CustomShippingOptions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Customers.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DraftOrders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PaymentSessions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Payments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Regions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::SalesChannels.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ShippingMethods.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Swaps.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cart_gift_cards::Relation::GiftCards.def() + } + fn via() -> Option { + Some(super::cart_gift_cards::Relation::Carts.def().rev()) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cart_discounts::Relation::Discounts.def() + } + fn via() -> Option { + Some(super::cart_discounts::Relation::Carts.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/claim_images.rs b/crates/model/src/v4/claim_images.rs new file mode 100644 index 0000000..3f05627 --- /dev/null +++ b/crates/model/src/v4/claim_images.rs @@ -0,0 +1,86 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "claim_images" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub claim_item_id: String, + pub url: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + ClaimItemId, + Url, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + ClaimItems, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::ClaimItemId => ColumnType::String(None).def(), + Self::Url => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::ClaimItems => Entity::belongs_to(super::claim_items::Entity) + .from(Column::ClaimItemId) + .to(super::claim_items::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ClaimItems.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/claim_item_tags.rs b/crates/model/src/v4/claim_item_tags.rs new file mode 100644 index 0000000..fbfcd4d --- /dev/null +++ b/crates/model/src/v4/claim_item_tags.rs @@ -0,0 +1,83 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "claim_item_tags" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub item_id: String, + pub tag_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + ItemId, + TagId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + ItemId, + TagId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + ClaimItems, + ClaimTags, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::ItemId => ColumnType::String(None).def(), + Self::TagId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::ClaimItems => Entity::belongs_to(super::claim_items::Entity) + .from(Column::ItemId) + .to(super::claim_items::Column::Id) + .into(), + Self::ClaimTags => Entity::belongs_to(super::claim_tags::Entity) + .from(Column::TagId) + .to(super::claim_tags::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ClaimItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ClaimTags.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/claim_items.rs b/crates/model/src/v4/claim_items.rs new file mode 100644 index 0000000..7d28504 --- /dev/null +++ b/crates/model/src/v4/claim_items.rs @@ -0,0 +1,139 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::ClaimItemReasons; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "claim_items" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub claim_order_id: String, + pub item_id: String, + pub variant_id: String, + pub reason: ClaimItemReasons, + pub note: Option, + pub quantity: i32, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + ClaimOrderId, + ItemId, + VariantId, + Reason, + Note, + Quantity, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + ClaimImages, + ClaimOrders, + LineItems, + ProductVariants, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::ClaimOrderId => ColumnType::String(None).def(), + Self::ItemId => ColumnType::String(None).def(), + Self::VariantId => ColumnType::String(None).def(), + Self::Reason => ClaimItemReasons::db_type().def(), + Self::Note => ColumnType::String(None).def().null(), + Self::Quantity => ColumnType::Integer.def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::ClaimImages => Entity::has_many(super::claim_images::Entity).into(), + Self::ClaimOrders => Entity::belongs_to(super::claim_orders::Entity) + .from(Column::ClaimOrderId) + .to(super::claim_orders::Column::Id) + .into(), + Self::LineItems => Entity::belongs_to(super::line_items::Entity) + .from(Column::ItemId) + .to(super::line_items::Column::Id) + .into(), + Self::ProductVariants => Entity::belongs_to(super::product_variants::Entity) + .from(Column::VariantId) + .to(super::product_variants::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ClaimImages.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ClaimOrders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ProductVariants.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::claim_item_tags::Relation::ClaimTags.def() + } + fn via() -> Option { + Some(super::claim_item_tags::Relation::ClaimItems.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/claim_orders.rs b/crates/model/src/v4/claim_orders.rs new file mode 100644 index 0000000..44733e4 --- /dev/null +++ b/crates/model/src/v4/claim_orders.rs @@ -0,0 +1,162 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::{ + ClaimOrderFulfillmentStatuses, ClaimOrderPaymentStatuses, ClaimOrderTypes, +}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "claim_orders" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub payment_status: ClaimOrderPaymentStatuses, + pub fulfillment_status: ClaimOrderFulfillmentStatuses, + pub r#type: ClaimOrderTypes, + pub order_id: String, + pub shipping_address_id: Option, + pub refund_amount: Option, + pub canceled_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, + pub idempotency_key: Option, + pub no_notification: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + PaymentStatus, + FulfillmentStatus, + Type, + OrderId, + ShippingAddressId, + RefundAmount, + CanceledAt, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, + IdempotencyKey, + NoNotification, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Addresses, + ClaimItems, + Fulfillments, + LineItems, + Orders, + Returns, + ShippingMethods, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::PaymentStatus => ClaimOrderPaymentStatuses::db_type().def(), + Self::FulfillmentStatus => ClaimOrderFulfillmentStatuses::db_type().def(), + Self::Type => ClaimOrderTypes::db_type().def(), + Self::OrderId => ColumnType::String(None).def(), + Self::ShippingAddressId => ColumnType::String(None).def().null(), + Self::RefundAmount => ColumnType::Integer.def().null(), + Self::CanceledAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::IdempotencyKey => ColumnType::String(None).def().null(), + Self::NoNotification => ColumnType::Boolean.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Addresses => Entity::belongs_to(super::addresses::Entity) + .from(Column::ShippingAddressId) + .to(super::addresses::Column::Id) + .into(), + Self::ClaimItems => Entity::has_many(super::claim_items::Entity).into(), + Self::Fulfillments => Entity::has_many(super::fulfillments::Entity).into(), + Self::LineItems => Entity::has_many(super::line_items::Entity).into(), + Self::Orders => Entity::belongs_to(super::orders::Entity) + .from(Column::OrderId) + .to(super::orders::Column::Id) + .into(), + Self::Returns => Entity::has_one(super::returns::Entity).into(), + Self::ShippingMethods => Entity::has_many(super::shipping_methods::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Addresses.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ClaimItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fulfillments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Returns.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ShippingMethods.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/claim_tags.rs b/crates/model/src/v4/claim_tags.rs new file mode 100644 index 0000000..088ada9 --- /dev/null +++ b/crates/model/src/v4/claim_tags.rs @@ -0,0 +1,79 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "claim_tags" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub value: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Value, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Value => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::claim_item_tags::Relation::ClaimItems.def() + } + fn via() -> Option { + Some(super::claim_item_tags::Relation::ClaimTags.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/countries.rs b/crates/model/src/v4/countries.rs new file mode 100644 index 0000000..f5f997e --- /dev/null +++ b/crates/model/src/v4/countries.rs @@ -0,0 +1,94 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "countries" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: i32, + pub iso_2: String, + pub iso_3: String, + pub num_code: i32, + pub name: String, + pub display_name: String, + pub region_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Iso2, + Iso3, + NumCode, + Name, + DisplayName, + RegionId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + true + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Addresses, + Regions, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::Integer.def(), + Self::Iso2 => ColumnType::String(None).def(), + Self::Iso3 => ColumnType::String(None).def(), + Self::NumCode => ColumnType::Integer.def(), + Self::Name => ColumnType::String(None).def(), + Self::DisplayName => ColumnType::String(None).def(), + Self::RegionId => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Addresses => Entity::has_many(super::addresses::Entity).into(), + Self::Regions => Entity::belongs_to(super::regions::Entity) + .from(Column::RegionId) + .to(super::regions::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Addresses.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Regions.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/currencies.rs b/crates/model/src/v4/currencies.rs new file mode 100644 index 0000000..79175a0 --- /dev/null +++ b/crates/model/src/v4/currencies.rs @@ -0,0 +1,109 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "currencies" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub code: String, + pub symbol: String, + pub symbol_native: String, + pub name: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Code, + Symbol, + SymbolNative, + Name, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Code, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + MoneyAmounts, + Orders, + Payments, + Regions, + Stores, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Code => ColumnType::String(None).def(), + Self::Symbol => ColumnType::String(None).def(), + Self::SymbolNative => ColumnType::String(None).def(), + Self::Name => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::MoneyAmounts => Entity::has_many(super::money_amounts::Entity).into(), + Self::Orders => Entity::has_many(super::orders::Entity).into(), + Self::Payments => Entity::has_many(super::payments::Entity).into(), + Self::Regions => Entity::has_many(super::regions::Entity).into(), + Self::Stores => Entity::has_many(super::stores::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::MoneyAmounts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Payments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Regions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::store_currencies::Relation::Stores.def() + } + fn via() -> Option { + Some(super::store_currencies::Relation::Currencies.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/custom_shipping_options.rs b/crates/model/src/v4/custom_shipping_options.rs new file mode 100644 index 0000000..6694e0a --- /dev/null +++ b/crates/model/src/v4/custom_shipping_options.rs @@ -0,0 +1,100 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "custom_shipping_options" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub price: i32, + pub shipping_option_id: String, + pub cart_id: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Price, + ShippingOptionId, + CartId, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Carts, + ShippingOptions, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Price => ColumnType::Integer.def(), + Self::ShippingOptionId => ColumnType::String(None).def(), + Self::CartId => ColumnType::String(None).def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Carts => Entity::belongs_to(super::carts::Entity) + .from(Column::CartId) + .to(super::carts::Column::Id) + .into(), + Self::ShippingOptions => Entity::belongs_to(super::shipping_options::Entity) + .from(Column::ShippingOptionId) + .to(super::shipping_options::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Carts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ShippingOptions.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/customer_group_customers.rs b/crates/model/src/v4/customer_group_customers.rs new file mode 100644 index 0000000..44fa048 --- /dev/null +++ b/crates/model/src/v4/customer_group_customers.rs @@ -0,0 +1,83 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "customer_group_customers" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub customer_group_id: String, + pub customer_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + CustomerGroupId, + CustomerId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + CustomerGroupId, + CustomerId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + CustomerGroups, + Customers, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::CustomerGroupId => ColumnType::String(None).def(), + Self::CustomerId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::CustomerGroups => Entity::belongs_to(super::customer_groups::Entity) + .from(Column::CustomerGroupId) + .to(super::customer_groups::Column::Id) + .into(), + Self::Customers => Entity::belongs_to(super::customers::Entity) + .from(Column::CustomerId) + .to(super::customers::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::CustomerGroups.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Customers.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/customer_groups.rs b/crates/model/src/v4/customer_groups.rs new file mode 100644 index 0000000..c318060 --- /dev/null +++ b/crates/model/src/v4/customer_groups.rs @@ -0,0 +1,109 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "customer_groups" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub name: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Name, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Name => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::customer_group_customers::Relation::Customers.def() + } + fn via() -> Option { + Some( + super::customer_group_customers::Relation::CustomerGroups + .def() + .rev(), + ) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::discount_condition_customer_groups::Relation::DiscountConditions.def() + } + fn via() -> Option { + Some( + super::discount_condition_customer_groups::Relation::CustomerGroups + .def() + .rev(), + ) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::price_list_customer_groups::Relation::PriceLists.def() + } + fn via() -> Option { + Some( + super::price_list_customer_groups::Relation::CustomerGroups + .def() + .rev(), + ) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/customers.rs b/crates/model/src/v4/customers.rs new file mode 100644 index 0000000..0984a59 --- /dev/null +++ b/crates/model/src/v4/customers.rs @@ -0,0 +1,138 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "customers" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub email: String, + pub first_name: Option, + pub last_name: Option, + pub billing_address_id: Option, + pub password_hash: Option, + pub phone: Option, + pub has_account: bool, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Email, + FirstName, + LastName, + BillingAddressId, + PasswordHash, + Phone, + HasAccount, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Addresses, + Carts, + Notifications, + Orders, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Email => ColumnType::String(None).def(), + Self::FirstName => ColumnType::String(None).def().null(), + Self::LastName => ColumnType::String(None).def().null(), + Self::BillingAddressId => ColumnType::String(None).def().null().unique(), + Self::PasswordHash => ColumnType::String(None).def().null(), + Self::Phone => ColumnType::String(None).def().null(), + Self::HasAccount => ColumnType::Boolean.def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Addresses => Entity::belongs_to(super::addresses::Entity) + .from(Column::BillingAddressId) + .to(super::addresses::Column::Id) + .into(), + Self::Carts => Entity::has_many(super::carts::Entity).into(), + Self::Notifications => Entity::has_many(super::notifications::Entity).into(), + Self::Orders => Entity::has_many(super::orders::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Addresses.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Carts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Notifications.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::customer_group_customers::Relation::CustomerGroups.def() + } + fn via() -> Option { + Some( + super::customer_group_customers::Relation::Customers + .def() + .rev(), + ) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/discount_condition_customer_groups.rs b/crates/model/src/v4/discount_condition_customer_groups.rs new file mode 100644 index 0000000..15fe930 --- /dev/null +++ b/crates/model/src/v4/discount_condition_customer_groups.rs @@ -0,0 +1,92 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "discount_condition_customer_groups" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub customer_group_id: String, + pub condition_id: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + CustomerGroupId, + ConditionId, + CreatedAt, + UpdatedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + CustomerGroupId, + ConditionId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + CustomerGroups, + DiscountConditions, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::CustomerGroupId => ColumnType::String(None).def(), + Self::ConditionId => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::CustomerGroups => Entity::belongs_to(super::customer_groups::Entity) + .from(Column::CustomerGroupId) + .to(super::customer_groups::Column::Id) + .into(), + Self::DiscountConditions => Entity::belongs_to(super::discount_conditions::Entity) + .from(Column::ConditionId) + .to(super::discount_conditions::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::CustomerGroups.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DiscountConditions.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/discount_condition_product_collections.rs b/crates/model/src/v4/discount_condition_product_collections.rs new file mode 100644 index 0000000..b5029e3 --- /dev/null +++ b/crates/model/src/v4/discount_condition_product_collections.rs @@ -0,0 +1,92 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "discount_condition_product_collections" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub product_collection_id: String, + pub condition_id: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + ProductCollectionId, + ConditionId, + CreatedAt, + UpdatedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + ProductCollectionId, + ConditionId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + DiscountConditions, + ProductCollections, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::ProductCollectionId => ColumnType::String(None).def(), + Self::ConditionId => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::DiscountConditions => Entity::belongs_to(super::discount_conditions::Entity) + .from(Column::ConditionId) + .to(super::discount_conditions::Column::Id) + .into(), + Self::ProductCollections => Entity::belongs_to(super::product_collections::Entity) + .from(Column::ProductCollectionId) + .to(super::product_collections::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DiscountConditions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ProductCollections.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/discount_condition_product_tags.rs b/crates/model/src/v4/discount_condition_product_tags.rs new file mode 100644 index 0000000..cd8baa6 --- /dev/null +++ b/crates/model/src/v4/discount_condition_product_tags.rs @@ -0,0 +1,92 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "discount_condition_product_tags" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub product_tag_id: String, + pub condition_id: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + ProductTagId, + ConditionId, + CreatedAt, + UpdatedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + ProductTagId, + ConditionId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + DiscountConditions, + ProductTags, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::ProductTagId => ColumnType::String(None).def(), + Self::ConditionId => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::DiscountConditions => Entity::belongs_to(super::discount_conditions::Entity) + .from(Column::ConditionId) + .to(super::discount_conditions::Column::Id) + .into(), + Self::ProductTags => Entity::belongs_to(super::product_tags::Entity) + .from(Column::ProductTagId) + .to(super::product_tags::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DiscountConditions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ProductTags.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/discount_condition_product_types.rs b/crates/model/src/v4/discount_condition_product_types.rs new file mode 100644 index 0000000..42dbb06 --- /dev/null +++ b/crates/model/src/v4/discount_condition_product_types.rs @@ -0,0 +1,92 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "discount_condition_product_types" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub product_type_id: String, + pub condition_id: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + ProductTypeId, + ConditionId, + CreatedAt, + UpdatedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + ProductTypeId, + ConditionId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + DiscountConditions, + ProductTypes, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::ProductTypeId => ColumnType::String(None).def(), + Self::ConditionId => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::DiscountConditions => Entity::belongs_to(super::discount_conditions::Entity) + .from(Column::ConditionId) + .to(super::discount_conditions::Column::Id) + .into(), + Self::ProductTypes => Entity::belongs_to(super::product_types::Entity) + .from(Column::ProductTypeId) + .to(super::product_types::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DiscountConditions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ProductTypes.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/discount_condition_products.rs b/crates/model/src/v4/discount_condition_products.rs new file mode 100644 index 0000000..16daf45 --- /dev/null +++ b/crates/model/src/v4/discount_condition_products.rs @@ -0,0 +1,92 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "discount_condition_products" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub product_id: String, + pub condition_id: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + ProductId, + ConditionId, + CreatedAt, + UpdatedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + ProductId, + ConditionId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + DiscountConditions, + Products, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::ProductId => ColumnType::String(None).def(), + Self::ConditionId => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::DiscountConditions => Entity::belongs_to(super::discount_conditions::Entity) + .from(Column::ConditionId) + .to(super::discount_conditions::Column::Id) + .into(), + Self::Products => Entity::belongs_to(super::products::Entity) + .from(Column::ProductId) + .to(super::products::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DiscountConditions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Products.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/discount_conditions.rs b/crates/model/src/v4/discount_conditions.rs new file mode 100644 index 0000000..b225638 --- /dev/null +++ b/crates/model/src/v4/discount_conditions.rs @@ -0,0 +1,156 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::{DiscountConditionOperators, DiscountConditionTypes}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "discount_conditions" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub r#type: DiscountConditionTypes, + pub operator: DiscountConditionOperators, + pub discount_rule_id: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Type, + Operator, + DiscountRuleId, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + DiscountRules, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Type => DiscountConditionTypes::db_type().def(), + Self::Operator => DiscountConditionOperators::db_type().def(), + Self::DiscountRuleId => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::DiscountRules => Entity::belongs_to(super::discount_rules::Entity) + .from(Column::DiscountRuleId) + .to(super::discount_rules::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DiscountRules.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::discount_condition_product_tags::Relation::ProductTags.def() + } + fn via() -> Option { + Some( + super::discount_condition_product_tags::Relation::DiscountConditions + .def() + .rev(), + ) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::discount_condition_customer_groups::Relation::CustomerGroups.def() + } + fn via() -> Option { + Some( + super::discount_condition_customer_groups::Relation::DiscountConditions + .def() + .rev(), + ) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::discount_condition_product_types::Relation::ProductTypes.def() + } + fn via() -> Option { + Some( + super::discount_condition_product_types::Relation::DiscountConditions + .def() + .rev(), + ) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::discount_condition_product_collections::Relation::ProductCollections.def() + } + fn via() -> Option { + Some( + super::discount_condition_product_collections::Relation::DiscountConditions + .def() + .rev(), + ) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::discount_condition_products::Relation::Products.def() + } + fn via() -> Option { + Some( + super::discount_condition_products::Relation::DiscountConditions + .def() + .rev(), + ) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/discount_regions.rs b/crates/model/src/v4/discount_regions.rs new file mode 100644 index 0000000..9471d7e --- /dev/null +++ b/crates/model/src/v4/discount_regions.rs @@ -0,0 +1,83 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "discount_regions" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub discount_id: String, + pub region_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + DiscountId, + RegionId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + DiscountId, + RegionId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Discounts, + Regions, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::DiscountId => ColumnType::String(None).def(), + Self::RegionId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Discounts => Entity::belongs_to(super::discounts::Entity) + .from(Column::DiscountId) + .to(super::discounts::Column::Id) + .into(), + Self::Regions => Entity::belongs_to(super::regions::Entity) + .from(Column::RegionId) + .to(super::regions::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Discounts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Regions.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/discount_rule_products.rs b/crates/model/src/v4/discount_rule_products.rs new file mode 100644 index 0000000..7ddbedc --- /dev/null +++ b/crates/model/src/v4/discount_rule_products.rs @@ -0,0 +1,83 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "discount_rule_products" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub discount_rule_id: String, + pub product_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + DiscountRuleId, + ProductId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + DiscountRuleId, + ProductId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + DiscountRules, + Products, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::DiscountRuleId => ColumnType::String(None).def(), + Self::ProductId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::DiscountRules => Entity::belongs_to(super::discount_rules::Entity) + .from(Column::DiscountRuleId) + .to(super::discount_rules::Column::Id) + .into(), + Self::Products => Entity::belongs_to(super::products::Entity) + .from(Column::ProductId) + .to(super::products::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DiscountRules.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Products.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/discount_rules.rs b/crates/model/src/v4/discount_rules.rs new file mode 100644 index 0000000..0207e90 --- /dev/null +++ b/crates/model/src/v4/discount_rules.rs @@ -0,0 +1,112 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::{DiscountRuleAllocations, DiscountRuleTypes}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "discount_rules" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub description: Option, + pub r#type: DiscountRuleTypes, + pub value: i32, + pub allocation: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Description, + Type, + Value, + Allocation, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + DiscountConditions, + Discounts, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Description => ColumnType::String(None).def().null(), + Self::Type => DiscountRuleTypes::db_type().def(), + Self::Value => ColumnType::Integer.def(), + Self::Allocation => DiscountRuleAllocations::db_type().def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::DiscountConditions => Entity::has_many(super::discount_conditions::Entity).into(), + Self::Discounts => Entity::has_many(super::discounts::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DiscountConditions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Discounts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::discount_rule_products::Relation::Products.def() + } + fn via() -> Option { + Some( + super::discount_rule_products::Relation::DiscountRules + .def() + .rev(), + ) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/discounts.rs b/crates/model/src/v4/discounts.rs new file mode 100644 index 0000000..d5dd01f --- /dev/null +++ b/crates/model/src/v4/discounts.rs @@ -0,0 +1,152 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "discounts" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub code: String, + pub is_dynamic: bool, + pub rule_id: Option, + pub is_disabled: bool, + pub parent_discount_id: Option, + pub starts_at: DateTimeWithTimeZone, + pub ends_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, + pub usage_limit: Option, + pub usage_count: i32, + pub valid_duration: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Code, + IsDynamic, + RuleId, + IsDisabled, + ParentDiscountId, + StartsAt, + EndsAt, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, + UsageLimit, + UsageCount, + ValidDuration, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + DiscountRules, + SelfRef, + LineItemAdjustments, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Code => ColumnType::String(None).def(), + Self::IsDynamic => ColumnType::Boolean.def(), + Self::RuleId => ColumnType::String(None).def().null(), + Self::IsDisabled => ColumnType::Boolean.def(), + Self::ParentDiscountId => ColumnType::String(None).def().null(), + Self::StartsAt => ColumnType::TimestampWithTimeZone.def(), + Self::EndsAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::UsageLimit => ColumnType::Integer.def().null(), + Self::UsageCount => ColumnType::Integer.def(), + Self::ValidDuration => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::DiscountRules => Entity::belongs_to(super::discount_rules::Entity) + .from(Column::RuleId) + .to(super::discount_rules::Column::Id) + .into(), + Self::SelfRef => Entity::belongs_to(Entity) + .from(Column::ParentDiscountId) + .to(Column::Id) + .into(), + Self::LineItemAdjustments => { + Entity::has_many(super::line_item_adjustments::Entity).into() + } + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DiscountRules.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItemAdjustments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::order_discounts::Relation::Orders.def() + } + fn via() -> Option { + Some(super::order_discounts::Relation::Discounts.def().rev()) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cart_discounts::Relation::Carts.def() + } + fn via() -> Option { + Some(super::cart_discounts::Relation::Discounts.def().rev()) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::discount_regions::Relation::Regions.def() + } + fn via() -> Option { + Some(super::discount_regions::Relation::Discounts.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/draft_orders.rs b/crates/model/src/v4/draft_orders.rs new file mode 100644 index 0000000..5fd5a1a --- /dev/null +++ b/crates/model/src/v4/draft_orders.rs @@ -0,0 +1,114 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::DraftOrderStatuses; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "draft_orders" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub status: DraftOrderStatuses, + pub display_id: i32, + pub cart_id: Option, + pub order_id: Option, + pub canceled_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub completed_at: Option, + pub metadata: Option, + pub idempotency_key: Option, + pub no_notification_order: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Status, + DisplayId, + CartId, + OrderId, + CanceledAt, + CreatedAt, + UpdatedAt, + CompletedAt, + Metadata, + IdempotencyKey, + NoNotificationOrder, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + true + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Carts, + Orders, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Status => DraftOrderStatuses::db_type().def(), + Self::DisplayId => ColumnType::Integer.def(), + Self::CartId => ColumnType::String(None).def().null().unique(), + Self::OrderId => ColumnType::String(None).def().null().unique(), + Self::CanceledAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::CompletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::IdempotencyKey => ColumnType::String(None).def().null(), + Self::NoNotificationOrder => ColumnType::Boolean.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Carts => Entity::belongs_to(super::carts::Entity) + .from(Column::CartId) + .to(super::carts::Column::Id) + .into(), + Self::Orders => Entity::belongs_to(super::orders::Entity) + .from(Column::OrderId) + .to(super::orders::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Carts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/fulfillment_items.rs b/crates/model/src/v4/fulfillment_items.rs new file mode 100644 index 0000000..c6f4030 --- /dev/null +++ b/crates/model/src/v4/fulfillment_items.rs @@ -0,0 +1,86 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "fulfillment_items" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub fulfillment_id: String, + pub item_id: String, + pub quantity: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + FulfillmentId, + ItemId, + Quantity, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + FulfillmentId, + ItemId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Fulfillments, + LineItems, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::FulfillmentId => ColumnType::String(None).def(), + Self::ItemId => ColumnType::String(None).def(), + Self::Quantity => ColumnType::Integer.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Fulfillments => Entity::belongs_to(super::fulfillments::Entity) + .from(Column::FulfillmentId) + .to(super::fulfillments::Column::Id) + .into(), + Self::LineItems => Entity::belongs_to(super::line_items::Entity) + .from(Column::ItemId) + .to(super::line_items::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fulfillments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItems.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/fulfillment_providers.rs b/crates/model/src/v4/fulfillment_providers.rs new file mode 100644 index 0000000..e89ac86 --- /dev/null +++ b/crates/model/src/v4/fulfillment_providers.rs @@ -0,0 +1,89 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "fulfillment_providers" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub is_installed: bool, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + IsInstalled, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Fulfillments, + ShippingOptions, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::IsInstalled => ColumnType::Boolean.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Fulfillments => Entity::has_many(super::fulfillments::Entity).into(), + Self::ShippingOptions => Entity::has_many(super::shipping_options::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fulfillments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ShippingOptions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::region_fulfillment_providers::Relation::Regions.def() + } + fn via() -> Option { + Some( + super::region_fulfillment_providers::Relation::FulfillmentProviders + .def() + .rev(), + ) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/fulfillments.rs b/crates/model/src/v4/fulfillments.rs new file mode 100644 index 0000000..0ff3721 --- /dev/null +++ b/crates/model/src/v4/fulfillments.rs @@ -0,0 +1,160 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "fulfillments" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub swap_id: Option, + pub order_id: Option, + pub tracking_numbers: Json, + pub data: Json, + pub shipped_at: Option, + pub canceled_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, + pub idempotency_key: Option, + pub provider_id: Option, + pub claim_order_id: Option, + pub no_notification: Option, + pub location_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + SwapId, + OrderId, + TrackingNumbers, + Data, + ShippedAt, + CanceledAt, + CreatedAt, + UpdatedAt, + Metadata, + IdempotencyKey, + ProviderId, + ClaimOrderId, + NoNotification, + LocationId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + ClaimOrders, + FulfillmentProviders, + Orders, + Swaps, + TrackingLinks, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::SwapId => ColumnType::String(None).def().null(), + Self::OrderId => ColumnType::String(None).def().null(), + Self::TrackingNumbers => ColumnType::JsonBinary.def(), + Self::Data => ColumnType::JsonBinary.def(), + Self::ShippedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CanceledAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::IdempotencyKey => ColumnType::String(None).def().null(), + Self::ProviderId => ColumnType::String(None).def().null(), + Self::ClaimOrderId => ColumnType::String(None).def().null(), + Self::NoNotification => ColumnType::Boolean.def().null(), + Self::LocationId => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::ClaimOrders => Entity::belongs_to(super::claim_orders::Entity) + .from(Column::ClaimOrderId) + .to(super::claim_orders::Column::Id) + .into(), + Self::FulfillmentProviders => Entity::belongs_to(super::fulfillment_providers::Entity) + .from(Column::ProviderId) + .to(super::fulfillment_providers::Column::Id) + .into(), + Self::Orders => Entity::belongs_to(super::orders::Entity) + .from(Column::OrderId) + .to(super::orders::Column::Id) + .into(), + Self::Swaps => Entity::belongs_to(super::swaps::Entity) + .from(Column::SwapId) + .to(super::swaps::Column::Id) + .into(), + Self::TrackingLinks => Entity::has_many(super::tracking_links::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ClaimOrders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::FulfillmentProviders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Swaps.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::TrackingLinks.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::fulfillment_items::Relation::LineItems.def() + } + fn via() -> Option { + Some(super::fulfillment_items::Relation::Fulfillments.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/gift_card_transactions.rs b/crates/model/src/v4/gift_card_transactions.rs new file mode 100644 index 0000000..428b3c7 --- /dev/null +++ b/crates/model/src/v4/gift_card_transactions.rs @@ -0,0 +1,97 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "gift_card_transactions" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub gift_card_id: String, + pub order_id: String, + pub amount: i32, + pub created_at: DateTimeWithTimeZone, + pub is_taxable: Option, + pub tax_rate: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + GiftCardId, + OrderId, + Amount, + CreatedAt, + IsTaxable, + TaxRate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + GiftCards, + Orders, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::GiftCardId => ColumnType::String(None).def(), + Self::OrderId => ColumnType::String(None).def(), + Self::Amount => ColumnType::Integer.def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::IsTaxable => ColumnType::Boolean.def().null(), + Self::TaxRate => ColumnType::Float.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::GiftCards => Entity::belongs_to(super::gift_cards::Entity) + .from(Column::GiftCardId) + .to(super::gift_cards::Column::Id) + .into(), + Self::Orders => Entity::belongs_to(super::orders::Entity) + .from(Column::OrderId) + .to(super::orders::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::GiftCards.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/gift_cards.rs b/crates/model/src/v4/gift_cards.rs new file mode 100644 index 0000000..2e051a2 --- /dev/null +++ b/crates/model/src/v4/gift_cards.rs @@ -0,0 +1,137 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "gift_cards" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub code: String, + pub value: i32, + pub balance: i32, + pub region_id: String, + pub order_id: Option, + pub is_disabled: bool, + pub ends_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, + pub tax_rate: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Code, + Value, + Balance, + RegionId, + OrderId, + IsDisabled, + EndsAt, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, + TaxRate, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + GiftCardTransactions, + Orders, + Regions, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Code => ColumnType::String(None).def(), + Self::Value => ColumnType::Integer.def(), + Self::Balance => ColumnType::Integer.def(), + Self::RegionId => ColumnType::String(None).def(), + Self::OrderId => ColumnType::String(None).def().null(), + Self::IsDisabled => ColumnType::Boolean.def(), + Self::EndsAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::TaxRate => ColumnType::Float.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::GiftCardTransactions => { + Entity::has_many(super::gift_card_transactions::Entity).into() + } + Self::Orders => Entity::belongs_to(super::orders::Entity) + .from(Column::OrderId) + .to(super::orders::Column::Id) + .into(), + Self::Regions => Entity::belongs_to(super::regions::Entity) + .from(Column::RegionId) + .to(super::regions::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::GiftCardTransactions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Regions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::cart_gift_cards::Relation::Carts.def() + } + fn via() -> Option { + Some(super::cart_gift_cards::Relation::GiftCards.def().rev()) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::order_gift_cards::Relation::Orders.def() + } + fn via() -> Option { + Some(super::order_gift_cards::Relation::GiftCards.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/idempotency_keys.rs b/crates/model/src/v4/idempotency_keys.rs new file mode 100644 index 0000000..80d206d --- /dev/null +++ b/crates/model/src/v4/idempotency_keys.rs @@ -0,0 +1,82 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "idempotency_keys" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub idempotency_key: String, + pub created_at: DateTimeWithTimeZone, + pub locked_at: Option, + pub request_method: Option, + pub request_params: Option, + pub request_path: Option, + pub response_code: Option, + pub response_body: Option, + pub recovery_point: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + IdempotencyKey, + CreatedAt, + LockedAt, + RequestMethod, + RequestParams, + RequestPath, + ResponseCode, + ResponseBody, + RecoveryPoint, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::IdempotencyKey => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::LockedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::RequestMethod => ColumnType::String(None).def().null(), + Self::RequestParams => ColumnType::JsonBinary.def().null(), + Self::RequestPath => ColumnType::String(None).def().null(), + Self::ResponseCode => ColumnType::Integer.def().null(), + Self::ResponseBody => ColumnType::JsonBinary.def().null(), + Self::RecoveryPoint => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/images.rs b/crates/model/src/v4/images.rs new file mode 100644 index 0000000..e9c2d19 --- /dev/null +++ b/crates/model/src/v4/images.rs @@ -0,0 +1,79 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "images" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub url: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Url, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Url => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::product_images::Relation::Products.def() + } + fn via() -> Option { + Some(super::product_images::Relation::Images.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/invites.rs b/crates/model/src/v4/invites.rs new file mode 100644 index 0000000..6c32a65 --- /dev/null +++ b/crates/model/src/v4/invites.rs @@ -0,0 +1,84 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::InviteRoles; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "invites" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub user_email: String, + pub role: Option, + pub accepted: bool, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, + pub token: String, + pub expires_at: DateTimeWithTimeZone, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + UserEmail, + Role, + Accepted, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, + Token, + ExpiresAt, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::UserEmail => ColumnType::String(None).def(), + Self::Role => InviteRoles::db_type().def().null(), + Self::Accepted => ColumnType::Boolean.def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::Token => ColumnType::String(None).def(), + Self::ExpiresAt => ColumnType::TimestampWithTimeZone.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/line_item_adjustments.rs b/crates/model/src/v4/line_item_adjustments.rs new file mode 100644 index 0000000..c98a244 --- /dev/null +++ b/crates/model/src/v4/line_item_adjustments.rs @@ -0,0 +1,94 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "line_item_adjustments" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub item_id: String, + pub description: String, + pub discount_id: Option, + pub amount: Decimal, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + ItemId, + Description, + DiscountId, + Amount, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Discounts, + LineItems, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::ItemId => ColumnType::String(None).def(), + Self::Description => ColumnType::String(None).def(), + Self::DiscountId => ColumnType::String(None).def().null(), + Self::Amount => ColumnType::Decimal(None).def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Discounts => Entity::belongs_to(super::discounts::Entity) + .from(Column::DiscountId) + .to(super::discounts::Column::Id) + .into(), + Self::LineItems => Entity::belongs_to(super::line_items::Entity) + .from(Column::ItemId) + .to(super::line_items::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Discounts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItems.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/line_item_tax_lines.rs b/crates/model/src/v4/line_item_tax_lines.rs new file mode 100644 index 0000000..9ce1bb0 --- /dev/null +++ b/crates/model/src/v4/line_item_tax_lines.rs @@ -0,0 +1,89 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "line_item_tax_lines" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub rate: f32, + pub name: String, + pub code: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, + pub item_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Rate, + Name, + Code, + CreatedAt, + UpdatedAt, + Metadata, + ItemId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + LineItems, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Rate => ColumnType::Float.def(), + Self::Name => ColumnType::String(None).def(), + Self::Code => ColumnType::String(None).def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::ItemId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::LineItems => Entity::belongs_to(super::line_items::Entity) + .from(Column::ItemId) + .to(super::line_items::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItems.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/line_items.rs b/crates/model/src/v4/line_items.rs new file mode 100644 index 0000000..e5483e0 --- /dev/null +++ b/crates/model/src/v4/line_items.rs @@ -0,0 +1,240 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "line_items" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub cart_id: Option, + pub order_id: Option, + pub swap_id: Option, + pub title: String, + pub description: Option, + pub thumbnail: Option, + pub is_giftcard: bool, + pub should_merge: bool, + pub allow_discounts: bool, + pub has_shipping: Option, + pub unit_price: i32, + pub variant_id: Option, + pub quantity: i32, + pub fulfilled_quantity: Option, + pub returned_quantity: Option, + pub shipped_quantity: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, + pub claim_order_id: Option, + pub is_return: bool, + pub original_item_id: Option, + pub order_edit_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + CartId, + OrderId, + SwapId, + Title, + Description, + Thumbnail, + IsGiftcard, + ShouldMerge, + AllowDiscounts, + HasShipping, + UnitPrice, + VariantId, + Quantity, + FulfilledQuantity, + ReturnedQuantity, + ShippedQuantity, + CreatedAt, + UpdatedAt, + Metadata, + ClaimOrderId, + IsReturn, + OriginalItemId, + OrderEditId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Carts, + ClaimItems, + ClaimOrders, + LineItemAdjustments, + LineItemTaxLines, + SelfRef, + OrderEdits, + Orders, + ProductVariants, + ReturnItems, + Swaps, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::CartId => ColumnType::String(None).def().null(), + Self::OrderId => ColumnType::String(None).def().null(), + Self::SwapId => ColumnType::String(None).def().null(), + Self::Title => ColumnType::String(None).def(), + Self::Description => ColumnType::String(None).def().null(), + Self::Thumbnail => ColumnType::String(None).def().null(), + Self::IsGiftcard => ColumnType::Boolean.def(), + Self::ShouldMerge => ColumnType::Boolean.def(), + Self::AllowDiscounts => ColumnType::Boolean.def(), + Self::HasShipping => ColumnType::Boolean.def().null(), + Self::UnitPrice => ColumnType::Integer.def(), + Self::VariantId => ColumnType::String(None).def().null(), + Self::Quantity => ColumnType::Integer.def(), + Self::FulfilledQuantity => ColumnType::Integer.def().null(), + Self::ReturnedQuantity => ColumnType::Integer.def().null(), + Self::ShippedQuantity => ColumnType::Integer.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::ClaimOrderId => ColumnType::String(None).def().null(), + Self::IsReturn => ColumnType::Boolean.def(), + Self::OriginalItemId => ColumnType::String(None).def().null(), + Self::OrderEditId => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Carts => Entity::belongs_to(super::carts::Entity) + .from(Column::CartId) + .to(super::carts::Column::Id) + .into(), + Self::ClaimItems => Entity::has_many(super::claim_items::Entity).into(), + Self::ClaimOrders => Entity::belongs_to(super::claim_orders::Entity) + .from(Column::ClaimOrderId) + .to(super::claim_orders::Column::Id) + .into(), + Self::LineItemAdjustments => { + Entity::has_many(super::line_item_adjustments::Entity).into() + } + Self::LineItemTaxLines => Entity::has_many(super::line_item_tax_lines::Entity).into(), + Self::SelfRef => Entity::belongs_to(Entity) + .from(Column::OriginalItemId) + .to(Column::Id) + .into(), + Self::OrderEdits => Entity::belongs_to(super::order_edits::Entity) + .from(Column::OrderEditId) + .to(super::order_edits::Column::Id) + .into(), + Self::Orders => Entity::belongs_to(super::orders::Entity) + .from(Column::OrderId) + .to(super::orders::Column::Id) + .into(), + Self::ProductVariants => Entity::belongs_to(super::product_variants::Entity) + .from(Column::VariantId) + .to(super::product_variants::Column::Id) + .into(), + Self::ReturnItems => Entity::has_many(super::return_items::Entity).into(), + Self::Swaps => Entity::belongs_to(super::swaps::Entity) + .from(Column::SwapId) + .to(super::swaps::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Carts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ClaimItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ClaimOrders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItemAdjustments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItemTaxLines.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::OrderEdits.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ProductVariants.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ReturnItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Swaps.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::fulfillment_items::Relation::Fulfillments.def() + } + fn via() -> Option { + Some(super::fulfillment_items::Relation::LineItems.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/migrations.rs b/crates/model/src/v4/migrations.rs new file mode 100644 index 0000000..b35c0b5 --- /dev/null +++ b/crates/model/src/v4/migrations.rs @@ -0,0 +1,61 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "migrations" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: i32, + pub timestamp: i64, + pub name: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Timestamp, + Name, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = i32; + fn auto_increment() -> bool { + true + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::Integer.def(), + Self::Timestamp => ColumnType::BigInteger.def(), + Self::Name => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/mod.rs b/crates/model/src/v4/mod.rs new file mode 100644 index 0000000..be2047c --- /dev/null +++ b/crates/model/src/v4/mod.rs @@ -0,0 +1,103 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +pub mod prelude ; + +pub mod addresses ; +pub mod analytics_configs ; +pub mod batch_jobs ; +pub mod cart_discounts ; +pub mod cart_gift_cards ; +pub mod carts ; +pub mod claim_images ; +pub mod claim_item_tags ; +pub mod claim_items ; +pub mod claim_orders ; +pub mod claim_tags ; +pub mod countries ; +pub mod currencies ; +pub mod custom_shipping_options ; +pub mod customer_group_customers ; +pub mod customer_groups ; +pub mod customers ; +pub mod discount_condition_customer_groups ; +pub mod discount_condition_product_collections ; +pub mod discount_condition_product_tags ; +pub mod discount_condition_product_types ; +pub mod discount_condition_products ; +pub mod discount_conditions ; +pub mod discount_regions ; +pub mod discount_rule_products ; +pub mod discount_rules ; +pub mod discounts ; +pub mod draft_orders ; +pub mod fulfillment_items ; +pub mod fulfillment_providers ; +pub mod fulfillments ; +pub mod gift_card_transactions ; +pub mod gift_cards ; +pub mod idempotency_keys ; +pub mod images ; +pub mod invites ; +pub mod line_item_adjustments ; +pub mod line_item_tax_lines ; +pub mod line_items ; +pub mod migrations ; +pub mod money_amounts ; +pub mod notes ; +pub mod notification_providers ; +pub mod notifications ; +pub mod oauth ; +pub mod order_discounts ; +pub mod order_edits ; +pub mod order_gift_cards ; +pub mod order_item_changes ; +pub mod orders ; +pub mod payment_collection_payments ; +pub mod payment_collection_sessions ; +pub mod payment_collections ; +pub mod payment_providers ; +pub mod payment_sessions ; +pub mod payments ; +pub mod price_list_customer_groups ; +pub mod price_lists ; +pub mod product_categories ; +pub mod product_category_products ; +pub mod product_collections ; +pub mod product_images ; +pub mod product_option_values ; +pub mod product_options ; +pub mod product_sales_channels ; +pub mod product_tags ; +pub mod product_tax_rates ; +pub mod product_to_tags ; +pub mod product_type_tax_rates ; +pub mod product_types ; +pub mod product_variant_inventory_items ; +pub mod product_variants ; +pub mod products ; +pub mod publishable_api_key_sales_channels ; +pub mod publishable_api_keys ; +pub mod refunds ; +pub mod region_fulfillment_providers ; +pub mod region_payment_providers ; +pub mod regions ; +pub mod return_items ; +pub mod return_reasons ; +pub mod returns ; +pub mod sales_channel_locations ; +pub mod sales_channels ; +pub mod shipping_method_tax_lines ; +pub mod shipping_methods ; +pub mod shipping_option_requirements ; +pub mod shipping_options ; +pub mod shipping_profiles ; +pub mod shipping_tax_rates ; +pub mod staged_jobs ; +pub mod store_currencies ; +pub mod stores ; +pub mod swaps ; +pub mod tax_providers ; +pub mod tax_rates ; +pub mod tracking_links ; +pub mod users ; +pub mod sea_orm_active_enums ; \ No newline at end of file diff --git a/crates/model/src/v4/money_amounts.rs b/crates/model/src/v4/money_amounts.rs new file mode 100644 index 0000000..426311f --- /dev/null +++ b/crates/model/src/v4/money_amounts.rs @@ -0,0 +1,131 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "money_amounts" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub currency_code: String, + pub amount: i32, + pub variant_id: Option, + pub region_id: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub min_quantity: Option, + pub max_quantity: Option, + pub price_list_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + CurrencyCode, + Amount, + VariantId, + RegionId, + CreatedAt, + UpdatedAt, + DeletedAt, + MinQuantity, + MaxQuantity, + PriceListId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Currencies, + PriceLists, + ProductVariants, + Regions, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::CurrencyCode => ColumnType::String(None).def(), + Self::Amount => ColumnType::Integer.def(), + Self::VariantId => ColumnType::String(None).def().null(), + Self::RegionId => ColumnType::String(None).def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::MinQuantity => ColumnType::Integer.def().null(), + Self::MaxQuantity => ColumnType::Integer.def().null(), + Self::PriceListId => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Currencies => Entity::belongs_to(super::currencies::Entity) + .from(Column::CurrencyCode) + .to(super::currencies::Column::Code) + .into(), + Self::PriceLists => Entity::belongs_to(super::price_lists::Entity) + .from(Column::PriceListId) + .to(super::price_lists::Column::Id) + .into(), + Self::ProductVariants => Entity::belongs_to(super::product_variants::Entity) + .from(Column::VariantId) + .to(super::product_variants::Column::Id) + .into(), + Self::Regions => Entity::belongs_to(super::regions::Entity) + .from(Column::RegionId) + .to(super::regions::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Currencies.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PriceLists.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ProductVariants.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Regions.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/notes.rs b/crates/model/src/v4/notes.rs new file mode 100644 index 0000000..3906a10 --- /dev/null +++ b/crates/model/src/v4/notes.rs @@ -0,0 +1,79 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "notes" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub value: String, + pub resource_type: String, + pub resource_id: String, + pub author_id: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Value, + ResourceType, + ResourceId, + AuthorId, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Value => ColumnType::String(None).def(), + Self::ResourceType => ColumnType::String(None).def(), + Self::ResourceId => ColumnType::String(None).def(), + Self::AuthorId => ColumnType::String(None).def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/notification_providers.rs b/crates/model/src/v4/notification_providers.rs new file mode 100644 index 0000000..e988cc1 --- /dev/null +++ b/crates/model/src/v4/notification_providers.rs @@ -0,0 +1,68 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "notification_providers" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub is_installed: bool, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + IsInstalled, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Notifications, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::IsInstalled => ColumnType::Boolean.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Notifications => Entity::has_many(super::notifications::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Notifications.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/notifications.rs b/crates/model/src/v4/notifications.rs new file mode 100644 index 0000000..f5a1c5a --- /dev/null +++ b/crates/model/src/v4/notifications.rs @@ -0,0 +1,116 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "notifications" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub event_name: Option, + pub resource_type: String, + pub resource_id: String, + pub customer_id: Option, + pub to: String, + pub data: Json, + pub parent_id: Option, + pub provider_id: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + EventName, + ResourceType, + ResourceId, + CustomerId, + To, + Data, + ParentId, + ProviderId, + CreatedAt, + UpdatedAt, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Customers, + NotificationProviders, + SelfRef, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::EventName => ColumnType::String(None).def().null(), + Self::ResourceType => ColumnType::String(None).def(), + Self::ResourceId => ColumnType::String(None).def(), + Self::CustomerId => ColumnType::String(None).def().null(), + Self::To => ColumnType::String(None).def(), + Self::Data => ColumnType::JsonBinary.def(), + Self::ParentId => ColumnType::String(None).def().null(), + Self::ProviderId => ColumnType::String(None).def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Customers => Entity::belongs_to(super::customers::Entity) + .from(Column::CustomerId) + .to(super::customers::Column::Id) + .into(), + Self::NotificationProviders => { + Entity::belongs_to(super::notification_providers::Entity) + .from(Column::ProviderId) + .to(super::notification_providers::Column::Id) + .into() + } + Self::SelfRef => Entity::belongs_to(Entity) + .from(Column::ParentId) + .to(Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Customers.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::NotificationProviders.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/oauth.rs b/crates/model/src/v4/oauth.rs new file mode 100644 index 0000000..5bb0d7e --- /dev/null +++ b/crates/model/src/v4/oauth.rs @@ -0,0 +1,70 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "oauth" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub display_name: String, + pub application_name: String, + pub install_url: Option, + pub uninstall_url: Option, + pub data: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + DisplayName, + ApplicationName, + InstallUrl, + UninstallUrl, + Data, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::DisplayName => ColumnType::String(None).def(), + Self::ApplicationName => ColumnType::String(None).def(), + Self::InstallUrl => ColumnType::String(None).def().null(), + Self::UninstallUrl => ColumnType::String(None).def().null(), + Self::Data => ColumnType::JsonBinary.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/order.rs b/crates/model/src/v4/order.rs new file mode 100644 index 0000000..1ed1d7f --- /dev/null +++ b/crates/model/src/v4/order.rs @@ -0,0 +1,250 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::{OrderFulfillmentStatuses, OrderPaymentStatuses, OrderStatuses}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "order" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub status: OrderStatuses, + pub fulfillment_status: OrderFulfillmentStatuses, + pub payment_status: OrderPaymentStatuses, + pub display_id: i32, + pub cart_id: Option, + pub customer_id: String, + pub email: String, + pub billing_address_id: Option, + pub shipping_address_id: Option, + pub region_id: String, + pub currency_code: String, + pub tax_rate: i32, + pub canceled_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, + pub idempotency_key: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Status, + FulfillmentStatus, + PaymentStatus, + DisplayId, + CartId, + CustomerId, + Email, + BillingAddressId, + ShippingAddressId, + RegionId, + CurrencyCode, + TaxRate, + CanceledAt, + CreatedAt, + UpdatedAt, + Metadata, + IdempotencyKey, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + true + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Addresses2, + Addresses1, + Cart, + Currencies, + Customers, + Fulfillments, + GiftCardTransactions, + GiftCards, + LineItems, + Payments, + Refunds, + Regions, + Return, + ShippingMethods, + Swap, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Status => OrderStatuses::db_type().def(), + Self::FulfillmentStatus => OrderFulfillmentStatuses::db_type().def(), + Self::PaymentStatus => OrderPaymentStatuses::db_type().def(), + Self::DisplayId => ColumnType::Integer.def(), + Self::CartId => ColumnType::String(None).def().null().unique(), + Self::CustomerId => ColumnType::String(None).def(), + Self::Email => ColumnType::String(None).def(), + Self::BillingAddressId => ColumnType::String(None).def().null(), + Self::ShippingAddressId => ColumnType::String(None).def().null(), + Self::RegionId => ColumnType::String(None).def(), + Self::CurrencyCode => ColumnType::String(None).def(), + Self::TaxRate => ColumnType::Integer.def(), + Self::CanceledAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::IdempotencyKey => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Addresses2 => Entity::belongs_to(super::addresses::Entity) + .from(Column::ShippingAddressId) + .to(super::addresses::Column::Id) + .into(), + Self::Addresses1 => Entity::belongs_to(super::addresses::Entity) + .from(Column::BillingAddressId) + .to(super::addresses::Column::Id) + .into(), + Self::Cart => Entity::belongs_to(super::cart::Entity) + .from(Column::CartId) + .to(super::cart::Column::Id) + .into(), + Self::Currencies => Entity::belongs_to(super::currencies::Entity) + .from(Column::CurrencyCode) + .to(super::currencies::Column::Code) + .into(), + Self::Customers => Entity::belongs_to(super::customers::Entity) + .from(Column::CustomerId) + .to(super::customers::Column::Id) + .into(), + Self::Fulfillments => Entity::has_many(super::fulfillments::Entity).into(), + Self::GiftCardTransactions => { + Entity::has_many(super::gift_card_transactions::Entity).into() + } + Self::GiftCards => Entity::has_one(super::gift_cards::Entity).into(), + Self::LineItems => Entity::has_many(super::line_items::Entity).into(), + Self::Payments => Entity::has_many(super::payments::Entity).into(), + Self::Refunds => Entity::has_many(super::refunds::Entity).into(), + Self::Regions => Entity::belongs_to(super::regions::Entity) + .from(Column::RegionId) + .to(super::regions::Column::Id) + .into(), + Self::Return => Entity::has_many(super::r#return::Entity).into(), + Self::ShippingMethods => Entity::has_many(super::shipping_methods::Entity).into(), + Self::Swap => Entity::has_many(super::swap::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Cart.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Currencies.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Customers.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fulfillments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::GiftCardTransactions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Payments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Refunds.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Regions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Return.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ShippingMethods.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Swap.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::order_discounts::Relation::Discounts.def() + } + fn via() -> Option { + Some(super::order_discounts::Relation::Order.def().rev()) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::order_gift_cards::Relation::GiftCards.def() + } + fn via() -> Option { + Some(super::order_gift_cards::Relation::Order.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/order_discounts.rs b/crates/model/src/v4/order_discounts.rs new file mode 100644 index 0000000..f7b4c9a --- /dev/null +++ b/crates/model/src/v4/order_discounts.rs @@ -0,0 +1,83 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "order_discounts" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub order_id: String, + pub discount_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + OrderId, + DiscountId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + OrderId, + DiscountId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Discounts, + Orders, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::OrderId => ColumnType::String(None).def(), + Self::DiscountId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Discounts => Entity::belongs_to(super::discounts::Entity) + .from(Column::DiscountId) + .to(super::discounts::Column::Id) + .into(), + Self::Orders => Entity::belongs_to(super::orders::Entity) + .from(Column::OrderId) + .to(super::orders::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Discounts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/order_edits.rs b/crates/model/src/v4/order_edits.rs new file mode 100644 index 0000000..be68abd --- /dev/null +++ b/crates/model/src/v4/order_edits.rs @@ -0,0 +1,140 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "order_edits" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub order_id: String, + pub internal_note: Option, + pub created_by: String, + pub requested_by: Option, + pub requested_at: Option, + pub confirmed_by: Option, + pub confirmed_at: Option, + pub declined_by: Option, + pub declined_reason: Option, + pub declined_at: Option, + pub canceled_by: Option, + pub canceled_at: Option, + pub payment_collection_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + CreatedAt, + UpdatedAt, + OrderId, + InternalNote, + CreatedBy, + RequestedBy, + RequestedAt, + ConfirmedBy, + ConfirmedAt, + DeclinedBy, + DeclinedReason, + DeclinedAt, + CanceledBy, + CanceledAt, + PaymentCollectionId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + LineItems, + OrderItemChanges, + Orders, + PaymentCollections, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::OrderId => ColumnType::String(None).def(), + Self::InternalNote => ColumnType::String(None).def().null(), + Self::CreatedBy => ColumnType::String(None).def(), + Self::RequestedBy => ColumnType::String(None).def().null(), + Self::RequestedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::ConfirmedBy => ColumnType::String(None).def().null(), + Self::ConfirmedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::DeclinedBy => ColumnType::String(None).def().null(), + Self::DeclinedReason => ColumnType::String(None).def().null(), + Self::DeclinedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CanceledBy => ColumnType::String(None).def().null(), + Self::CanceledAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::PaymentCollectionId => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::LineItems => Entity::has_many(super::line_items::Entity).into(), + Self::OrderItemChanges => Entity::has_many(super::order_item_changes::Entity).into(), + Self::Orders => Entity::belongs_to(super::orders::Entity) + .from(Column::OrderId) + .to(super::orders::Column::Id) + .into(), + Self::PaymentCollections => Entity::belongs_to(super::payment_collections::Entity) + .from(Column::PaymentCollectionId) + .to(super::payment_collections::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::OrderItemChanges.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PaymentCollections.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/order_gift_cards.rs b/crates/model/src/v4/order_gift_cards.rs new file mode 100644 index 0000000..ece8f4f --- /dev/null +++ b/crates/model/src/v4/order_gift_cards.rs @@ -0,0 +1,83 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "order_gift_cards" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub order_id: String, + pub gift_card_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + OrderId, + GiftCardId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + OrderId, + GiftCardId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + GiftCards, + Orders, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::OrderId => ColumnType::String(None).def(), + Self::GiftCardId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::GiftCards => Entity::belongs_to(super::gift_cards::Entity) + .from(Column::GiftCardId) + .to(super::gift_cards::Column::Id) + .into(), + Self::Orders => Entity::belongs_to(super::orders::Entity) + .from(Column::OrderId) + .to(super::orders::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::GiftCards.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/order_item_changes.rs b/crates/model/src/v4/order_item_changes.rs new file mode 100644 index 0000000..7f1d14a --- /dev/null +++ b/crates/model/src/v4/order_item_changes.rs @@ -0,0 +1,101 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::OrderItemChangeTypes; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "order_item_changes" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub r#type: OrderItemChangeTypes, + pub order_edit_id: String, + pub original_line_item_id: Option, + pub line_item_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + CreatedAt, + UpdatedAt, + DeletedAt, + Type, + OrderEditId, + OriginalLineItemId, + LineItemId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + LineItems2, + LineItems1, + OrderEdits, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Type => OrderItemChangeTypes::db_type().def(), + Self::OrderEditId => ColumnType::String(None).def(), + Self::OriginalLineItemId => ColumnType::String(None).def().null(), + Self::LineItemId => ColumnType::String(None).def().null().unique(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::LineItems2 => Entity::belongs_to(super::line_items::Entity) + .from(Column::LineItemId) + .to(super::line_items::Column::Id) + .into(), + Self::LineItems1 => Entity::belongs_to(super::line_items::Entity) + .from(Column::OriginalLineItemId) + .to(super::line_items::Column::Id) + .into(), + Self::OrderEdits => Entity::belongs_to(super::order_edits::Entity) + .from(Column::OrderEditId) + .to(super::order_edits::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::OrderEdits.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/orders.rs b/crates/model/src/v4/orders.rs new file mode 100644 index 0000000..07344af --- /dev/null +++ b/crates/model/src/v4/orders.rs @@ -0,0 +1,300 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::{OrderFulfillmentStatuses, OrderPaymentStatuses, OrderStatuses}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "orders" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub status: OrderStatuses, + pub fulfillment_status: OrderFulfillmentStatuses, + pub payment_status: OrderPaymentStatuses, + pub display_id: i32, + pub cart_id: Option, + pub customer_id: String, + pub email: String, + pub billing_address_id: Option, + pub shipping_address_id: Option, + pub region_id: String, + pub currency_code: String, + pub tax_rate: Option, + pub canceled_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, + pub idempotency_key: Option, + pub draft_order_id: Option, + pub no_notification: Option, + pub external_id: Option, + pub sales_channel_id: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Status, + FulfillmentStatus, + PaymentStatus, + DisplayId, + CartId, + CustomerId, + Email, + BillingAddressId, + ShippingAddressId, + RegionId, + CurrencyCode, + TaxRate, + CanceledAt, + CreatedAt, + UpdatedAt, + Metadata, + IdempotencyKey, + DraftOrderId, + NoNotification, + ExternalId, + SalesChannelId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + true + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Addresses2, + Addresses1, + Carts, + ClaimOrders, + Currencies, + Customers, + DraftOrders, + Fulfillments, + GiftCardTransactions, + GiftCards, + LineItems, + OrderEdits, + Payments, + Refunds, + Regions, + Returns, + SalesChannels, + ShippingMethods, + Swaps, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Status => OrderStatuses::db_type().def(), + Self::FulfillmentStatus => OrderFulfillmentStatuses::db_type().def(), + Self::PaymentStatus => OrderPaymentStatuses::db_type().def(), + Self::DisplayId => ColumnType::Integer.def(), + Self::CartId => ColumnType::String(None).def().null().unique(), + Self::CustomerId => ColumnType::String(None).def(), + Self::Email => ColumnType::String(None).def(), + Self::BillingAddressId => ColumnType::String(None).def().null(), + Self::ShippingAddressId => ColumnType::String(None).def().null(), + Self::RegionId => ColumnType::String(None).def(), + Self::CurrencyCode => ColumnType::String(None).def(), + Self::TaxRate => ColumnType::Float.def().null(), + Self::CanceledAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::IdempotencyKey => ColumnType::String(None).def().null(), + Self::DraftOrderId => ColumnType::String(None).def().null().unique(), + Self::NoNotification => ColumnType::Boolean.def().null(), + Self::ExternalId => ColumnType::String(None).def().null(), + Self::SalesChannelId => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Addresses2 => Entity::belongs_to(super::addresses::Entity) + .from(Column::ShippingAddressId) + .to(super::addresses::Column::Id) + .into(), + Self::Addresses1 => Entity::belongs_to(super::addresses::Entity) + .from(Column::BillingAddressId) + .to(super::addresses::Column::Id) + .into(), + Self::Carts => Entity::belongs_to(super::carts::Entity) + .from(Column::CartId) + .to(super::carts::Column::Id) + .into(), + Self::ClaimOrders => Entity::has_many(super::claim_orders::Entity).into(), + Self::Currencies => Entity::belongs_to(super::currencies::Entity) + .from(Column::CurrencyCode) + .to(super::currencies::Column::Code) + .into(), + Self::Customers => Entity::belongs_to(super::customers::Entity) + .from(Column::CustomerId) + .to(super::customers::Column::Id) + .into(), + Self::DraftOrders => Entity::belongs_to(super::draft_orders::Entity) + .from(Column::DraftOrderId) + .to(super::draft_orders::Column::Id) + .into(), + Self::Fulfillments => Entity::has_many(super::fulfillments::Entity).into(), + Self::GiftCardTransactions => { + Entity::has_many(super::gift_card_transactions::Entity).into() + } + Self::GiftCards => Entity::has_many(super::gift_cards::Entity).into(), + Self::LineItems => Entity::has_many(super::line_items::Entity).into(), + Self::OrderEdits => Entity::has_many(super::order_edits::Entity).into(), + Self::Payments => Entity::has_many(super::payments::Entity).into(), + Self::Refunds => Entity::has_many(super::refunds::Entity).into(), + Self::Regions => Entity::belongs_to(super::regions::Entity) + .from(Column::RegionId) + .to(super::regions::Column::Id) + .into(), + Self::Returns => Entity::has_many(super::returns::Entity).into(), + Self::SalesChannels => Entity::belongs_to(super::sales_channels::Entity) + .from(Column::SalesChannelId) + .to(super::sales_channels::Column::Id) + .into(), + Self::ShippingMethods => Entity::has_many(super::shipping_methods::Entity).into(), + Self::Swaps => Entity::has_many(super::swaps::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Carts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ClaimOrders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Currencies.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Customers.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::DraftOrders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fulfillments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::GiftCardTransactions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::OrderEdits.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Payments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Refunds.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Regions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Returns.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::SalesChannels.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ShippingMethods.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Swaps.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::order_discounts::Relation::Discounts.def() + } + fn via() -> Option { + Some(super::order_discounts::Relation::Orders.def().rev()) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::order_gift_cards::Relation::GiftCards.def() + } + fn via() -> Option { + Some(super::order_gift_cards::Relation::Orders.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/payment_collection_payments.rs b/crates/model/src/v4/payment_collection_payments.rs new file mode 100644 index 0000000..a1cefe6 --- /dev/null +++ b/crates/model/src/v4/payment_collection_payments.rs @@ -0,0 +1,83 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "payment_collection_payments" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub payment_collection_id: String, + pub payment_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + PaymentCollectionId, + PaymentId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + PaymentCollectionId, + PaymentId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + PaymentCollections, + Payments, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::PaymentCollectionId => ColumnType::String(None).def(), + Self::PaymentId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::PaymentCollections => Entity::belongs_to(super::payment_collections::Entity) + .from(Column::PaymentCollectionId) + .to(super::payment_collections::Column::Id) + .into(), + Self::Payments => Entity::belongs_to(super::payments::Entity) + .from(Column::PaymentId) + .to(super::payments::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PaymentCollections.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Payments.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/payment_collection_sessions.rs b/crates/model/src/v4/payment_collection_sessions.rs new file mode 100644 index 0000000..a725e91 --- /dev/null +++ b/crates/model/src/v4/payment_collection_sessions.rs @@ -0,0 +1,83 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "payment_collection_sessions" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub payment_collection_id: String, + pub payment_session_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + PaymentCollectionId, + PaymentSessionId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + PaymentCollectionId, + PaymentSessionId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + PaymentCollections, + PaymentSessions, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::PaymentCollectionId => ColumnType::String(None).def(), + Self::PaymentSessionId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::PaymentCollections => Entity::belongs_to(super::payment_collections::Entity) + .from(Column::PaymentCollectionId) + .to(super::payment_collections::Column::Id) + .into(), + Self::PaymentSessions => Entity::belongs_to(super::payment_sessions::Entity) + .from(Column::PaymentSessionId) + .to(super::payment_sessions::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PaymentCollections.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PaymentSessions.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/payment_collections.rs b/crates/model/src/v4/payment_collections.rs new file mode 100644 index 0000000..960b267 --- /dev/null +++ b/crates/model/src/v4/payment_collections.rs @@ -0,0 +1,140 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::{PaymentCollectionStatuses, PaymentCollectionTypes}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "payment_collections" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub r#type: PaymentCollectionTypes, + pub status: PaymentCollectionStatuses, + pub description: Option, + pub amount: i32, + pub authorized_amount: Option, + pub region_id: String, + pub currency_code: String, + pub metadata: Option, + pub created_by: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + CreatedAt, + UpdatedAt, + DeletedAt, + Type, + Status, + Description, + Amount, + AuthorizedAmount, + RegionId, + CurrencyCode, + Metadata, + CreatedBy, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + OrderEdits, + Regions, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Type => PaymentCollectionTypes::db_type().def(), + Self::Status => PaymentCollectionStatuses::db_type().def(), + Self::Description => ColumnType::Text.def().null(), + Self::Amount => ColumnType::Integer.def(), + Self::AuthorizedAmount => ColumnType::Integer.def().null(), + Self::RegionId => ColumnType::String(None).def(), + Self::CurrencyCode => ColumnType::String(None).def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::CreatedBy => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::OrderEdits => Entity::has_many(super::order_edits::Entity).into(), + Self::Regions => Entity::belongs_to(super::regions::Entity) + .from(Column::RegionId) + .to(super::regions::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::OrderEdits.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Regions.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::payment_collection_payments::Relation::Payments.def() + } + fn via() -> Option { + Some( + super::payment_collection_payments::Relation::PaymentCollections + .def() + .rev(), + ) + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::payment_collection_sessions::Relation::PaymentSessions.def() + } + fn via() -> Option { + Some( + super::payment_collection_sessions::Relation::PaymentCollections + .def() + .rev(), + ) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/payment_providers.rs b/crates/model/src/v4/payment_providers.rs new file mode 100644 index 0000000..910b6e5 --- /dev/null +++ b/crates/model/src/v4/payment_providers.rs @@ -0,0 +1,71 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "payment_providers" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub is_installed: bool, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + IsInstalled, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::IsInstalled => ColumnType::Boolean.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::region_payment_providers::Relation::Regions.def() + } + fn via() -> Option { + Some( + super::region_payment_providers::Relation::PaymentProviders + .def() + .rev(), + ) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/payment_sessions.rs b/crates/model/src/v4/payment_sessions.rs new file mode 100644 index 0000000..57415d1 --- /dev/null +++ b/crates/model/src/v4/payment_sessions.rs @@ -0,0 +1,116 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::PaymentSessionStatuses; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "payment_sessions" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub cart_id: Option, + pub provider_id: String, + pub is_selected: Option, + pub status: PaymentSessionStatuses, + pub data: Json, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub idempotency_key: Option, + pub payment_authorized_at: Option, + pub amount: Option, + pub is_initiated: bool, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + CartId, + ProviderId, + IsSelected, + Status, + Data, + CreatedAt, + UpdatedAt, + IdempotencyKey, + PaymentAuthorizedAt, + Amount, + IsInitiated, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Carts, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::CartId => ColumnType::String(None).def().null(), + Self::ProviderId => ColumnType::String(None).def(), + Self::IsSelected => ColumnType::Boolean.def().null(), + Self::Status => PaymentSessionStatuses::db_type().def(), + Self::Data => ColumnType::JsonBinary.def(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::IdempotencyKey => ColumnType::String(None).def().null(), + Self::PaymentAuthorizedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Amount => ColumnType::Integer.def().null(), + Self::IsInitiated => ColumnType::Boolean.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Carts => Entity::belongs_to(super::carts::Entity) + .from(Column::CartId) + .to(super::carts::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Carts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::payment_collection_sessions::Relation::PaymentCollections.def() + } + fn via() -> Option { + Some( + super::payment_collection_sessions::Relation::PaymentSessions + .def() + .rev(), + ) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/payments.rs b/crates/model/src/v4/payments.rs new file mode 100644 index 0000000..7acf93f --- /dev/null +++ b/crates/model/src/v4/payments.rs @@ -0,0 +1,164 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "payments" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub swap_id: Option, + pub cart_id: Option, + pub order_id: Option, + pub amount: i32, + pub currency_code: String, + pub amount_refunded: i32, + pub provider_id: String, + pub data: Json, + pub captured_at: Option, + pub canceled_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, + pub idempotency_key: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + SwapId, + CartId, + OrderId, + Amount, + CurrencyCode, + AmountRefunded, + ProviderId, + Data, + CapturedAt, + CanceledAt, + CreatedAt, + UpdatedAt, + Metadata, + IdempotencyKey, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Carts, + Currencies, + Orders, + Refunds, + Swaps, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::SwapId => ColumnType::String(None).def().null().unique(), + Self::CartId => ColumnType::String(None).def().null(), + Self::OrderId => ColumnType::String(None).def().null(), + Self::Amount => ColumnType::Integer.def(), + Self::CurrencyCode => ColumnType::String(None).def(), + Self::AmountRefunded => ColumnType::Integer.def(), + Self::ProviderId => ColumnType::String(None).def(), + Self::Data => ColumnType::JsonBinary.def(), + Self::CapturedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CanceledAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::IdempotencyKey => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Carts => Entity::belongs_to(super::carts::Entity) + .from(Column::CartId) + .to(super::carts::Column::Id) + .into(), + Self::Currencies => Entity::belongs_to(super::currencies::Entity) + .from(Column::CurrencyCode) + .to(super::currencies::Column::Code) + .into(), + Self::Orders => Entity::belongs_to(super::orders::Entity) + .from(Column::OrderId) + .to(super::orders::Column::Id) + .into(), + Self::Refunds => Entity::has_many(super::refunds::Entity).into(), + Self::Swaps => Entity::belongs_to(super::swaps::Entity) + .from(Column::SwapId) + .to(super::swaps::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Carts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Currencies.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Orders.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Refunds.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Swaps.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::payment_collection_payments::Relation::PaymentCollections.def() + } + fn via() -> Option { + Some( + super::payment_collection_payments::Relation::Payments + .def() + .rev(), + ) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/prelude.rs b/crates/model/src/v4/prelude.rs new file mode 100644 index 0000000..57a5f36 --- /dev/null +++ b/crates/model/src/v4/prelude.rs @@ -0,0 +1,100 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +pub use super :: addresses :: Entity as Addresses ; +pub use super :: analytics_configs :: Entity as AnalyticsConfigs ; +pub use super :: batch_jobs :: Entity as BatchJobs ; +pub use super :: cart_discounts :: Entity as CartDiscounts ; +pub use super :: cart_gift_cards :: Entity as CartGiftCards ; +pub use super :: carts :: Entity as Carts ; +pub use super :: claim_images :: Entity as ClaimImages ; +pub use super :: claim_item_tags :: Entity as ClaimItemTags ; +pub use super :: claim_items :: Entity as ClaimItems ; +pub use super :: claim_orders :: Entity as ClaimOrders ; +pub use super :: claim_tags :: Entity as ClaimTags ; +pub use super :: countries :: Entity as Countries ; +pub use super :: currencies :: Entity as Currencies ; +pub use super :: custom_shipping_options :: Entity as CustomShippingOptions ; +pub use super :: customer_group_customers :: Entity as CustomerGroupCustomers ; +pub use super :: customer_groups :: Entity as CustomerGroups ; +pub use super :: customers :: Entity as Customers ; +pub use super :: discount_condition_customer_groups :: Entity as DiscountConditionCustomerGroups ; +pub use super :: discount_condition_product_collections :: Entity as DiscountConditionProductCollections ; +pub use super :: discount_condition_product_tags :: Entity as DiscountConditionProductTags ; +pub use super :: discount_condition_product_types :: Entity as DiscountConditionProductTypes ; +pub use super :: discount_condition_products :: Entity as DiscountConditionProducts ; +pub use super :: discount_conditions :: Entity as DiscountConditions ; +pub use super :: discount_regions :: Entity as DiscountRegions ; +pub use super :: discount_rule_products :: Entity as DiscountRuleProducts ; +pub use super :: discount_rules :: Entity as DiscountRules ; +pub use super :: discounts :: Entity as Discounts ; +pub use super :: draft_orders :: Entity as DraftOrders ; +pub use super :: fulfillment_items :: Entity as FulfillmentItems ; +pub use super :: fulfillment_providers :: Entity as FulfillmentProviders ; +pub use super :: fulfillments :: Entity as Fulfillments ; +pub use super :: gift_card_transactions :: Entity as GiftCardTransactions ; +pub use super :: gift_cards :: Entity as GiftCards ; +pub use super :: idempotency_keys :: Entity as IdempotencyKeys ; +pub use super :: images :: Entity as Images ; +pub use super :: invites :: Entity as Invites ; +pub use super :: line_item_adjustments :: Entity as LineItemAdjustments ; +pub use super :: line_item_tax_lines :: Entity as LineItemTaxLines ; +pub use super :: line_items :: Entity as LineItems ; +pub use super :: migrations :: Entity as Migrations ; +pub use super :: money_amounts :: Entity as MoneyAmounts ; +pub use super :: notes :: Entity as Notes ; +pub use super :: notification_providers :: Entity as NotificationProviders ; +pub use super :: notifications :: Entity as Notifications ; +pub use super :: oauth :: Entity as Oauth ; +pub use super :: order_discounts :: Entity as OrderDiscounts ; +pub use super :: order_edits :: Entity as OrderEdits ; +pub use super :: order_gift_cards :: Entity as OrderGiftCards ; +pub use super :: order_item_changes :: Entity as OrderItemChanges ; +pub use super :: orders :: Entity as Orders ; +pub use super :: payment_collection_payments :: Entity as PaymentCollectionPayments ; +pub use super :: payment_collection_sessions :: Entity as PaymentCollectionSessions ; +pub use super :: payment_collections :: Entity as PaymentCollections ; +pub use super :: payment_providers :: Entity as PaymentProviders ; +pub use super :: payment_sessions :: Entity as PaymentSessions ; +pub use super :: payments :: Entity as Payments ; +pub use super :: price_list_customer_groups :: Entity as PriceListCustomerGroups ; +pub use super :: price_lists :: Entity as PriceLists ; +pub use super :: product_categories :: Entity as ProductCategories ; +pub use super :: product_category_products :: Entity as ProductCategoryProducts ; +pub use super :: product_collections :: Entity as ProductCollections ; +pub use super :: product_images :: Entity as ProductImages ; +pub use super :: product_option_values :: Entity as ProductOptionValues ; +pub use super :: product_options :: Entity as ProductOptions ; +pub use super :: product_sales_channels :: Entity as ProductSalesChannels ; +pub use super :: product_tags :: Entity as ProductTags ; +pub use super :: product_tax_rates :: Entity as ProductTaxRates ; +pub use super :: product_to_tags :: Entity as ProductToTags ; +pub use super :: product_type_tax_rates :: Entity as ProductTypeTaxRates ; +pub use super :: product_types :: Entity as ProductTypes ; +pub use super :: product_variant_inventory_items :: Entity as ProductVariantInventoryItems ; +pub use super :: product_variants :: Entity as ProductVariants ; +pub use super :: products :: Entity as Products ; +pub use super :: publishable_api_key_sales_channels :: Entity as PublishableApiKeySalesChannels ; +pub use super :: publishable_api_keys :: Entity as PublishableApiKeys ; +pub use super :: refunds :: Entity as Refunds ; +pub use super :: region_fulfillment_providers :: Entity as RegionFulfillmentProviders ; +pub use super :: region_payment_providers :: Entity as RegionPaymentProviders ; +pub use super :: regions :: Entity as Regions ; +pub use super :: return_items :: Entity as ReturnItems ; +pub use super :: return_reasons :: Entity as ReturnReasons ; +pub use super :: returns :: Entity as Returns ; +pub use super :: sales_channel_locations :: Entity as SalesChannelLocations ; +pub use super :: sales_channels :: Entity as SalesChannels ; +pub use super :: shipping_method_tax_lines :: Entity as ShippingMethodTaxLines ; +pub use super :: shipping_methods :: Entity as ShippingMethods ; +pub use super :: shipping_option_requirements :: Entity as ShippingOptionRequirements ; +pub use super :: shipping_options :: Entity as ShippingOptions ; +pub use super :: shipping_profiles :: Entity as ShippingProfiles ; +pub use super :: shipping_tax_rates :: Entity as ShippingTaxRates ; +pub use super :: staged_jobs :: Entity as StagedJobs ; +pub use super :: store_currencies :: Entity as StoreCurrencies ; +pub use super :: stores :: Entity as Stores ; +pub use super :: swaps :: Entity as Swaps ; +pub use super :: tax_providers :: Entity as TaxProviders ; +pub use super :: tax_rates :: Entity as TaxRates ; +pub use super :: tracking_links :: Entity as TrackingLinks ; +pub use super :: users :: Entity as Users ; \ No newline at end of file diff --git a/crates/model/src/v4/price_list_customer_groups.rs b/crates/model/src/v4/price_list_customer_groups.rs new file mode 100644 index 0000000..4e68577 --- /dev/null +++ b/crates/model/src/v4/price_list_customer_groups.rs @@ -0,0 +1,83 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "price_list_customer_groups" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub price_list_id: String, + pub customer_group_id: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + PriceListId, + CustomerGroupId, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + PriceListId, + CustomerGroupId, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = (String, String); + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + CustomerGroups, + PriceLists, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::PriceListId => ColumnType::String(None).def(), + Self::CustomerGroupId => ColumnType::String(None).def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::CustomerGroups => Entity::belongs_to(super::customer_groups::Entity) + .from(Column::CustomerGroupId) + .to(super::customer_groups::Column::Id) + .into(), + Self::PriceLists => Entity::belongs_to(super::price_lists::Entity) + .from(Column::PriceListId) + .to(super::price_lists::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::CustomerGroups.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::PriceLists.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/price_lists.rs b/crates/model/src/v4/price_lists.rs new file mode 100644 index 0000000..61a2e8d --- /dev/null +++ b/crates/model/src/v4/price_lists.rs @@ -0,0 +1,107 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::{PriceListStatuses, PriceListTypes}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "price_lists" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub name: String, + pub description: String, + pub r#type: PriceListTypes, + pub status: PriceListStatuses, + pub starts_at: Option, + pub ends_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Name, + Description, + Type, + Status, + StartsAt, + EndsAt, + CreatedAt, + UpdatedAt, + DeletedAt, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + MoneyAmounts, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Name => ColumnType::String(None).def(), + Self::Description => ColumnType::String(None).def(), + Self::Type => PriceListTypes::db_type().def(), + Self::Status => PriceListStatuses::db_type().def(), + Self::StartsAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::EndsAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::MoneyAmounts => Entity::has_many(super::money_amounts::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::MoneyAmounts.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::price_list_customer_groups::Relation::CustomerGroups.def() + } + fn via() -> Option { + Some( + super::price_list_customer_groups::Relation::PriceLists + .def() + .rev(), + ) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/product_categories.rs b/crates/model/src/v4/product_categories.rs new file mode 100644 index 0000000..bb6c08a --- /dev/null +++ b/crates/model/src/v4/product_categories.rs @@ -0,0 +1,97 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "product_categories" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub name: String, + pub handle: String, + pub parent_category_id: Option, + pub mpath: Option, + pub is_active: Option, + pub is_internal: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub rank: i32, + pub description: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Name, + Handle, + ParentCategoryId, + Mpath, + IsActive, + IsInternal, + CreatedAt, + UpdatedAt, + Rank, + Description, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + ProductCategoryProducts, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Name => ColumnType::Text.def(), + Self::Handle => ColumnType::Text.def(), + Self::ParentCategoryId => ColumnType::String(None).def().null(), + Self::Mpath => ColumnType::Text.def().null(), + Self::IsActive => ColumnType::Boolean.def().null(), + Self::IsInternal => ColumnType::Boolean.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Rank => ColumnType::Integer.def(), + Self::Description => ColumnType::Text.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::ProductCategoryProducts => { + Entity::has_many(super::product_category_products::Entity).into() + } + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ProductCategoryProducts.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/product_category_products.rs b/crates/model/src/v4/product_category_products.rs new file mode 100644 index 0000000..8399542 --- /dev/null +++ b/crates/model/src/v4/product_category_products.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_category_products" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub product_category_id : String , pub product_id : String , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { ProductCategoryId , ProductId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ProductCategories , Products , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: ProductCategoryId => ColumnType :: String (None) . def () , Self :: ProductId => ColumnType :: String (None) . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ProductCategories => Entity :: belongs_to (super :: product_categories :: Entity) . from (Column :: ProductCategoryId) . to (super :: product_categories :: Column :: Id) . into () , Self :: Products => Entity :: belongs_to (super :: products :: Entity) . from (Column :: ProductId) . to (super :: products :: Column :: Id) . into () , } } } + +impl Related < super :: product_categories :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductCategories . def () } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { Relation :: Products . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_collections.rs b/crates/model/src/v4/product_collections.rs new file mode 100644 index 0000000..f6a3e53 --- /dev/null +++ b/crates/model/src/v4/product_collections.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_collections" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub title : String , pub handle : Option < String > , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Title , Handle , CreatedAt , UpdatedAt , DeletedAt , Metadata , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Products , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Title => ColumnType :: String (None) . def () , Self :: Handle => ColumnType :: String (None) . def () . null () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Products => Entity :: has_many (super :: products :: Entity) . into () , } } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { Relation :: Products . def () } } + +impl Related < super :: discount_conditions :: Entity > for Entity { fn to () -> RelationDef { super :: discount_condition_product_collections :: Relation :: DiscountConditions . def () } fn via () -> Option < RelationDef > { Some (super :: discount_condition_product_collections :: Relation :: ProductCollections . def () . rev ()) } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_images.rs b/crates/model/src/v4/product_images.rs new file mode 100644 index 0000000..5a37b7a --- /dev/null +++ b/crates/model/src/v4/product_images.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_images" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub product_id : String , pub image_id : String , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { ProductId , ImageId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { ProductId , ImageId , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = (String , String) ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Images , Products , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: ProductId => ColumnType :: String (None) . def () , Self :: ImageId => ColumnType :: String (None) . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Images => Entity :: belongs_to (super :: images :: Entity) . from (Column :: ImageId) . to (super :: images :: Column :: Id) . into () , Self :: Products => Entity :: belongs_to (super :: products :: Entity) . from (Column :: ProductId) . to (super :: products :: Column :: Id) . into () , } } } + +impl Related < super :: images :: Entity > for Entity { fn to () -> RelationDef { Relation :: Images . def () } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { Relation :: Products . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_option_values.rs b/crates/model/src/v4/product_option_values.rs new file mode 100644 index 0000000..84a6548 --- /dev/null +++ b/crates/model/src/v4/product_option_values.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_option_values" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub value : String , pub option_id : String , pub variant_id : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Value , OptionId , VariantId , CreatedAt , UpdatedAt , DeletedAt , Metadata , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ProductOptions , ProductVariants , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Value => ColumnType :: String (None) . def () , Self :: OptionId => ColumnType :: String (None) . def () , Self :: VariantId => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ProductOptions => Entity :: belongs_to (super :: product_options :: Entity) . from (Column :: OptionId) . to (super :: product_options :: Column :: Id) . into () , Self :: ProductVariants => Entity :: belongs_to (super :: product_variants :: Entity) . from (Column :: VariantId) . to (super :: product_variants :: Column :: Id) . into () , } } } + +impl Related < super :: product_options :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductOptions . def () } } + +impl Related < super :: product_variants :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductVariants . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_options.rs b/crates/model/src/v4/product_options.rs new file mode 100644 index 0000000..e40c520 --- /dev/null +++ b/crates/model/src/v4/product_options.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_options" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub title : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , pub product_id : Option < String > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Title , CreatedAt , UpdatedAt , DeletedAt , Metadata , ProductId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ProductOptionValues , Products , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Title => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: ProductId => ColumnType :: String (None) . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ProductOptionValues => Entity :: has_many (super :: product_option_values :: Entity) . into () , Self :: Products => Entity :: belongs_to (super :: products :: Entity) . from (Column :: ProductId) . to (super :: products :: Column :: Id) . into () , } } } + +impl Related < super :: product_option_values :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductOptionValues . def () } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { Relation :: Products . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_sales_channels.rs b/crates/model/src/v4/product_sales_channels.rs new file mode 100644 index 0000000..32ad014 --- /dev/null +++ b/crates/model/src/v4/product_sales_channels.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_sales_channels" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub product_id : String , pub sales_channel_id : String , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { ProductId , SalesChannelId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { ProductId , SalesChannelId , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = (String , String) ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Products , SalesChannels , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: ProductId => ColumnType :: String (None) . def () , Self :: SalesChannelId => ColumnType :: String (None) . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Products => Entity :: belongs_to (super :: products :: Entity) . from (Column :: ProductId) . to (super :: products :: Column :: Id) . into () , Self :: SalesChannels => Entity :: belongs_to (super :: sales_channels :: Entity) . from (Column :: SalesChannelId) . to (super :: sales_channels :: Column :: Id) . into () , } } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { Relation :: Products . def () } } + +impl Related < super :: sales_channels :: Entity > for Entity { fn to () -> RelationDef { Relation :: SalesChannels . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_tags.rs b/crates/model/src/v4/product_tags.rs new file mode 100644 index 0000000..e29bf99 --- /dev/null +++ b/crates/model/src/v4/product_tags.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_tags" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub value : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Value , CreatedAt , UpdatedAt , DeletedAt , Metadata , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Value => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { panic ! ("No RelationDef") } } + +impl Related < super :: discount_conditions :: Entity > for Entity { fn to () -> RelationDef { super :: discount_condition_product_tags :: Relation :: DiscountConditions . def () } fn via () -> Option < RelationDef > { Some (super :: discount_condition_product_tags :: Relation :: ProductTags . def () . rev ()) } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { super :: product_to_tags :: Relation :: Products . def () } fn via () -> Option < RelationDef > { Some (super :: product_to_tags :: Relation :: ProductTags . def () . rev ()) } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_tax_rates.rs b/crates/model/src/v4/product_tax_rates.rs new file mode 100644 index 0000000..159b046 --- /dev/null +++ b/crates/model/src/v4/product_tax_rates.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_tax_rates" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub product_id : String , pub rate_id : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub metadata : Option < Json > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { ProductId , RateId , CreatedAt , UpdatedAt , Metadata , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { ProductId , RateId , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = (String , String) ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Products , TaxRates , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: ProductId => ColumnType :: String (None) . def () , Self :: RateId => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Products => Entity :: belongs_to (super :: products :: Entity) . from (Column :: ProductId) . to (super :: products :: Column :: Id) . into () , Self :: TaxRates => Entity :: belongs_to (super :: tax_rates :: Entity) . from (Column :: RateId) . to (super :: tax_rates :: Column :: Id) . into () , } } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { Relation :: Products . def () } } + +impl Related < super :: tax_rates :: Entity > for Entity { fn to () -> RelationDef { Relation :: TaxRates . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_to_tags.rs b/crates/model/src/v4/product_to_tags.rs new file mode 100644 index 0000000..62f7937 --- /dev/null +++ b/crates/model/src/v4/product_to_tags.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_to_tags" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub product_id : String , pub product_tag_id : String , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { ProductId , ProductTagId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { ProductId , ProductTagId , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = (String , String) ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ProductTags , Products , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: ProductId => ColumnType :: String (None) . def () , Self :: ProductTagId => ColumnType :: String (None) . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ProductTags => Entity :: belongs_to (super :: product_tags :: Entity) . from (Column :: ProductTagId) . to (super :: product_tags :: Column :: Id) . into () , Self :: Products => Entity :: belongs_to (super :: products :: Entity) . from (Column :: ProductId) . to (super :: products :: Column :: Id) . into () , } } } + +impl Related < super :: product_tags :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductTags . def () } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { Relation :: Products . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_type_tax_rates.rs b/crates/model/src/v4/product_type_tax_rates.rs new file mode 100644 index 0000000..e3c6503 --- /dev/null +++ b/crates/model/src/v4/product_type_tax_rates.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_type_tax_rates" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub product_type_id : String , pub rate_id : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub metadata : Option < Json > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { ProductTypeId , RateId , CreatedAt , UpdatedAt , Metadata , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { ProductTypeId , RateId , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = (String , String) ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ProductTypes , TaxRates , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: ProductTypeId => ColumnType :: String (None) . def () , Self :: RateId => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ProductTypes => Entity :: belongs_to (super :: product_types :: Entity) . from (Column :: ProductTypeId) . to (super :: product_types :: Column :: Id) . into () , Self :: TaxRates => Entity :: belongs_to (super :: tax_rates :: Entity) . from (Column :: RateId) . to (super :: tax_rates :: Column :: Id) . into () , } } } + +impl Related < super :: product_types :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductTypes . def () } } + +impl Related < super :: tax_rates :: Entity > for Entity { fn to () -> RelationDef { Relation :: TaxRates . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_types.rs b/crates/model/src/v4/product_types.rs new file mode 100644 index 0000000..6732327 --- /dev/null +++ b/crates/model/src/v4/product_types.rs @@ -0,0 +1,31 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_types" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub value : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Value , CreatedAt , UpdatedAt , DeletedAt , Metadata , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Products , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Value => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Products => Entity :: has_many (super :: products :: Entity) . into () , } } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { Relation :: Products . def () } } + +impl Related < super :: tax_rates :: Entity > for Entity { fn to () -> RelationDef { super :: product_type_tax_rates :: Relation :: TaxRates . def () } fn via () -> Option < RelationDef > { Some (super :: product_type_tax_rates :: Relation :: ProductTypes . def () . rev ()) } } + +impl Related < super :: discount_conditions :: Entity > for Entity { fn to () -> RelationDef { super :: discount_condition_product_types :: Relation :: DiscountConditions . def () } fn via () -> Option < RelationDef > { Some (super :: discount_condition_product_types :: Relation :: ProductTypes . def () . rev ()) } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_variant_inventory_items.rs b/crates/model/src/v4/product_variant_inventory_items.rs new file mode 100644 index 0000000..41f520f --- /dev/null +++ b/crates/model/src/v4/product_variant_inventory_items.rs @@ -0,0 +1,25 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_variant_inventory_items" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub inventory_item_id : String , pub variant_id : String , pub required_quantity : i32 , pub deleted_at : Option < DateTimeWithTimeZone > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , CreatedAt , UpdatedAt , InventoryItemId , VariantId , RequiredQuantity , DeletedAt , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: InventoryItemId => ColumnType :: Text . def () , Self :: VariantId => ColumnType :: Text . def () , Self :: RequiredQuantity => ColumnType :: Integer . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { panic ! ("No RelationDef") } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/product_variants.rs b/crates/model/src/v4/product_variants.rs new file mode 100644 index 0000000..535d562 --- /dev/null +++ b/crates/model/src/v4/product_variants.rs @@ -0,0 +1,35 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "product_variants" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub title : String , pub product_id : String , pub sku : Option < String > , pub barcode : Option < String > , pub ean : Option < String > , pub upc : Option < String > , pub inventory_quantity : i32 , pub allow_backorder : bool , pub manage_inventory : bool , pub hs_code : Option < String > , pub origin_country : Option < String > , pub mid_code : Option < String > , pub material : Option < String > , pub weight : Option < i32 > , pub length : Option < i32 > , pub height : Option < i32 > , pub width : Option < i32 > , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , pub variant_rank : Option < i32 > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Title , ProductId , Sku , Barcode , Ean , Upc , InventoryQuantity , AllowBackorder , ManageInventory , HsCode , OriginCountry , MidCode , Material , Weight , Length , Height , Width , CreatedAt , UpdatedAt , DeletedAt , Metadata , VariantRank , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ClaimItems , LineItems , MoneyAmounts , ProductOptionValues , Products , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Title => ColumnType :: String (None) . def () , Self :: ProductId => ColumnType :: String (None) . def () , Self :: Sku => ColumnType :: String (None) . def () . null () , Self :: Barcode => ColumnType :: String (None) . def () . null () , Self :: Ean => ColumnType :: String (None) . def () . null () , Self :: Upc => ColumnType :: String (None) . def () . null () , Self :: InventoryQuantity => ColumnType :: Integer . def () , Self :: AllowBackorder => ColumnType :: Boolean . def () , Self :: ManageInventory => ColumnType :: Boolean . def () , Self :: HsCode => ColumnType :: String (None) . def () . null () , Self :: OriginCountry => ColumnType :: String (None) . def () . null () , Self :: MidCode => ColumnType :: String (None) . def () . null () , Self :: Material => ColumnType :: String (None) . def () . null () , Self :: Weight => ColumnType :: Integer . def () . null () , Self :: Length => ColumnType :: Integer . def () . null () , Self :: Height => ColumnType :: Integer . def () . null () , Self :: Width => ColumnType :: Integer . def () . null () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: VariantRank => ColumnType :: Integer . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ClaimItems => Entity :: has_many (super :: claim_items :: Entity) . into () , Self :: LineItems => Entity :: has_many (super :: line_items :: Entity) . into () , Self :: MoneyAmounts => Entity :: has_many (super :: money_amounts :: Entity) . into () , Self :: ProductOptionValues => Entity :: has_many (super :: product_option_values :: Entity) . into () , Self :: Products => Entity :: belongs_to (super :: products :: Entity) . from (Column :: ProductId) . to (super :: products :: Column :: Id) . into () , } } } + +impl Related < super :: claim_items :: Entity > for Entity { fn to () -> RelationDef { Relation :: ClaimItems . def () } } + +impl Related < super :: line_items :: Entity > for Entity { fn to () -> RelationDef { Relation :: LineItems . def () } } + +impl Related < super :: money_amounts :: Entity > for Entity { fn to () -> RelationDef { Relation :: MoneyAmounts . def () } } + +impl Related < super :: product_option_values :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductOptionValues . def () } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { Relation :: Products . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/products.rs b/crates/model/src/v4/products.rs new file mode 100644 index 0000000..0eb3eab --- /dev/null +++ b/crates/model/src/v4/products.rs @@ -0,0 +1,49 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; use super :: sea_orm_active_enums :: ProductStatuses ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "products" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub title : String , pub subtitle : Option < String > , pub description : Option < String > , pub handle : Option < String > , pub is_giftcard : bool , pub thumbnail : Option < String > , pub profile_id : String , pub weight : Option < i32 > , pub length : Option < i32 > , pub height : Option < i32 > , pub width : Option < i32 > , pub hs_code : Option < String > , pub origin_country : Option < String > , pub mid_code : Option < String > , pub material : Option < String > , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , pub collection_id : Option < String > , pub type_id : Option < String > , pub discountable : bool , pub status : ProductStatuses , pub external_id : Option < String > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Title , Subtitle , Description , Handle , IsGiftcard , Thumbnail , ProfileId , Weight , Length , Height , Width , HsCode , OriginCountry , MidCode , Material , CreatedAt , UpdatedAt , DeletedAt , Metadata , CollectionId , TypeId , Discountable , Status , ExternalId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ProductCategoryProducts , ProductCollections , ProductOptions , ProductTypes , ProductVariants , ShippingProfiles , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Title => ColumnType :: String (None) . def () , Self :: Subtitle => ColumnType :: String (None) . def () . null () , Self :: Description => ColumnType :: String (None) . def () . null () , Self :: Handle => ColumnType :: String (None) . def () . null () , Self :: IsGiftcard => ColumnType :: Boolean . def () , Self :: Thumbnail => ColumnType :: String (None) . def () . null () , Self :: ProfileId => ColumnType :: String (None) . def () , Self :: Weight => ColumnType :: Integer . def () . null () , Self :: Length => ColumnType :: Integer . def () . null () , Self :: Height => ColumnType :: Integer . def () . null () , Self :: Width => ColumnType :: Integer . def () . null () , Self :: HsCode => ColumnType :: String (None) . def () . null () , Self :: OriginCountry => ColumnType :: String (None) . def () . null () , Self :: MidCode => ColumnType :: String (None) . def () . null () , Self :: Material => ColumnType :: String (None) . def () . null () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: CollectionId => ColumnType :: String (None) . def () . null () , Self :: TypeId => ColumnType :: String (None) . def () . null () , Self :: Discountable => ColumnType :: Boolean . def () , Self :: Status => ProductStatuses :: db_type () . def () , Self :: ExternalId => ColumnType :: String (None) . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ProductCategoryProducts => Entity :: has_many (super :: product_category_products :: Entity) . into () , Self :: ProductCollections => Entity :: belongs_to (super :: product_collections :: Entity) . from (Column :: CollectionId) . to (super :: product_collections :: Column :: Id) . into () , Self :: ProductOptions => Entity :: has_many (super :: product_options :: Entity) . into () , Self :: ProductTypes => Entity :: belongs_to (super :: product_types :: Entity) . from (Column :: TypeId) . to (super :: product_types :: Column :: Id) . into () , Self :: ProductVariants => Entity :: has_many (super :: product_variants :: Entity) . into () , Self :: ShippingProfiles => Entity :: belongs_to (super :: shipping_profiles :: Entity) . from (Column :: ProfileId) . to (super :: shipping_profiles :: Column :: Id) . into () , } } } + +impl Related < super :: product_category_products :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductCategoryProducts . def () } } + +impl Related < super :: product_collections :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductCollections . def () } } + +impl Related < super :: product_options :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductOptions . def () } } + +impl Related < super :: product_types :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductTypes . def () } } + +impl Related < super :: product_variants :: Entity > for Entity { fn to () -> RelationDef { Relation :: ProductVariants . def () } } + +impl Related < super :: shipping_profiles :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingProfiles . def () } } + +impl Related < super :: tax_rates :: Entity > for Entity { fn to () -> RelationDef { super :: product_tax_rates :: Relation :: TaxRates . def () } fn via () -> Option < RelationDef > { Some (super :: product_tax_rates :: Relation :: Products . def () . rev ()) } } + +impl Related < super :: product_tags :: Entity > for Entity { fn to () -> RelationDef { super :: product_to_tags :: Relation :: ProductTags . def () } fn via () -> Option < RelationDef > { Some (super :: product_to_tags :: Relation :: Products . def () . rev ()) } } + +impl Related < super :: images :: Entity > for Entity { fn to () -> RelationDef { super :: product_images :: Relation :: Images . def () } fn via () -> Option < RelationDef > { Some (super :: product_images :: Relation :: Products . def () . rev ()) } } + +impl Related < super :: sales_channels :: Entity > for Entity { fn to () -> RelationDef { super :: product_sales_channels :: Relation :: SalesChannels . def () } fn via () -> Option < RelationDef > { Some (super :: product_sales_channels :: Relation :: Products . def () . rev ()) } } + +impl Related < super :: discount_rules :: Entity > for Entity { fn to () -> RelationDef { super :: discount_rule_products :: Relation :: DiscountRules . def () } fn via () -> Option < RelationDef > { Some (super :: discount_rule_products :: Relation :: Products . def () . rev ()) } } + +impl Related < super :: discount_conditions :: Entity > for Entity { fn to () -> RelationDef { super :: discount_condition_products :: Relation :: DiscountConditions . def () } fn via () -> Option < RelationDef > { Some (super :: discount_condition_products :: Relation :: Products . def () . rev ()) } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/publishable_api_key_sales_channels.rs b/crates/model/src/v4/publishable_api_key_sales_channels.rs new file mode 100644 index 0000000..c6a417c --- /dev/null +++ b/crates/model/src/v4/publishable_api_key_sales_channels.rs @@ -0,0 +1,25 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "publishable_api_key_sales_channels" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub sales_channel_id : String , pub publishable_key_id : String , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { SalesChannelId , PublishableKeyId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { SalesChannelId , PublishableKeyId , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = (String , String) ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: SalesChannelId => ColumnType :: String (None) . def () , Self :: PublishableKeyId => ColumnType :: String (None) . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { panic ! ("No RelationDef") } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/publishable_api_keys.rs b/crates/model/src/v4/publishable_api_keys.rs new file mode 100644 index 0000000..83109ba --- /dev/null +++ b/crates/model/src/v4/publishable_api_keys.rs @@ -0,0 +1,25 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "publishable_api_keys" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub created_by : Option < String > , pub revoked_by : Option < String > , pub revoked_at : Option < DateTimeWithTimeZone > , pub title : String , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , CreatedAt , UpdatedAt , CreatedBy , RevokedBy , RevokedAt , Title , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: CreatedBy => ColumnType :: String (None) . def () . null () , Self :: RevokedBy => ColumnType :: String (None) . def () . null () , Self :: RevokedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Title => ColumnType :: String (None) . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { panic ! ("No RelationDef") } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/refunds.rs b/crates/model/src/v4/refunds.rs new file mode 100644 index 0000000..31c5c2d --- /dev/null +++ b/crates/model/src/v4/refunds.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; use super :: sea_orm_active_enums :: RefundReasons ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "refunds" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub order_id : Option < String > , pub amount : i32 , pub note : Option < String > , pub reason : RefundReasons , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub metadata : Option < Json > , pub idempotency_key : Option < String > , pub payment_id : Option < String > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , OrderId , Amount , Note , Reason , CreatedAt , UpdatedAt , Metadata , IdempotencyKey , PaymentId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Orders , Payments , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: OrderId => ColumnType :: String (None) . def () . null () , Self :: Amount => ColumnType :: Integer . def () , Self :: Note => ColumnType :: String (None) . def () . null () , Self :: Reason => RefundReasons :: db_type () . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: IdempotencyKey => ColumnType :: String (None) . def () . null () , Self :: PaymentId => ColumnType :: String (None) . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Orders => Entity :: belongs_to (super :: orders :: Entity) . from (Column :: OrderId) . to (super :: orders :: Column :: Id) . into () , Self :: Payments => Entity :: belongs_to (super :: payments :: Entity) . from (Column :: PaymentId) . to (super :: payments :: Column :: Id) . into () , } } } + +impl Related < super :: orders :: Entity > for Entity { fn to () -> RelationDef { Relation :: Orders . def () } } + +impl Related < super :: payments :: Entity > for Entity { fn to () -> RelationDef { Relation :: Payments . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/region_fulfillment_providers.rs b/crates/model/src/v4/region_fulfillment_providers.rs new file mode 100644 index 0000000..1d0ab46 --- /dev/null +++ b/crates/model/src/v4/region_fulfillment_providers.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "region_fulfillment_providers" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub region_id : String , pub provider_id : String , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { RegionId , ProviderId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { RegionId , ProviderId , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = (String , String) ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { FulfillmentProviders , Regions , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: RegionId => ColumnType :: String (None) . def () , Self :: ProviderId => ColumnType :: String (None) . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: FulfillmentProviders => Entity :: belongs_to (super :: fulfillment_providers :: Entity) . from (Column :: ProviderId) . to (super :: fulfillment_providers :: Column :: Id) . into () , Self :: Regions => Entity :: belongs_to (super :: regions :: Entity) . from (Column :: RegionId) . to (super :: regions :: Column :: Id) . into () , } } } + +impl Related < super :: fulfillment_providers :: Entity > for Entity { fn to () -> RelationDef { Relation :: FulfillmentProviders . def () } } + +impl Related < super :: regions :: Entity > for Entity { fn to () -> RelationDef { Relation :: Regions . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/region_payment_providers.rs b/crates/model/src/v4/region_payment_providers.rs new file mode 100644 index 0000000..2bbb851 --- /dev/null +++ b/crates/model/src/v4/region_payment_providers.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "region_payment_providers" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub region_id : String , pub provider_id : String , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { RegionId , ProviderId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { RegionId , ProviderId , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = (String , String) ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { PaymentProviders , Regions , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: RegionId => ColumnType :: String (None) . def () , Self :: ProviderId => ColumnType :: String (None) . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: PaymentProviders => Entity :: belongs_to (super :: payment_providers :: Entity) . from (Column :: ProviderId) . to (super :: payment_providers :: Column :: Id) . into () , Self :: Regions => Entity :: belongs_to (super :: regions :: Entity) . from (Column :: RegionId) . to (super :: regions :: Column :: Id) . into () , } } } + +impl Related < super :: payment_providers :: Entity > for Entity { fn to () -> RelationDef { Relation :: PaymentProviders . def () } } + +impl Related < super :: regions :: Entity > for Entity { fn to () -> RelationDef { Relation :: Regions . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/regions.rs b/crates/model/src/v4/regions.rs new file mode 100644 index 0000000..7b850b7 --- /dev/null +++ b/crates/model/src/v4/regions.rs @@ -0,0 +1,51 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "regions" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Serialize , Deserialize)] pub struct Model { pub id : String , pub name : String , pub currency_code : String , pub tax_rate : f32 , pub tax_code : Option < String > , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , pub gift_cards_taxable : bool , pub automatic_taxes : bool , pub tax_provider_id : Option < String > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Name , CurrencyCode , TaxRate , TaxCode , CreatedAt , UpdatedAt , DeletedAt , Metadata , GiftCardsTaxable , AutomaticTaxes , TaxProviderId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Carts , Countries , Currencies , GiftCards , MoneyAmounts , Orders , PaymentCollections , ShippingOptions , TaxProviders , TaxRates , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Name => ColumnType :: String (None) . def () , Self :: CurrencyCode => ColumnType :: String (None) . def () , Self :: TaxRate => ColumnType :: Float . def () , Self :: TaxCode => ColumnType :: String (None) . def () . null () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: GiftCardsTaxable => ColumnType :: Boolean . def () , Self :: AutomaticTaxes => ColumnType :: Boolean . def () , Self :: TaxProviderId => ColumnType :: String (None) . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Carts => Entity :: has_many (super :: carts :: Entity) . into () , Self :: Countries => Entity :: has_many (super :: countries :: Entity) . into () , Self :: Currencies => Entity :: belongs_to (super :: currencies :: Entity) . from (Column :: CurrencyCode) . to (super :: currencies :: Column :: Code) . into () , Self :: GiftCards => Entity :: has_many (super :: gift_cards :: Entity) . into () , Self :: MoneyAmounts => Entity :: has_many (super :: money_amounts :: Entity) . into () , Self :: Orders => Entity :: has_many (super :: orders :: Entity) . into () , Self :: PaymentCollections => Entity :: has_many (super :: payment_collections :: Entity) . into () , Self :: ShippingOptions => Entity :: has_many (super :: shipping_options :: Entity) . into () , Self :: TaxProviders => Entity :: belongs_to (super :: tax_providers :: Entity) . from (Column :: TaxProviderId) . to (super :: tax_providers :: Column :: Id) . into () , Self :: TaxRates => Entity :: has_many (super :: tax_rates :: Entity) . into () , } } } + +impl Related < super :: carts :: Entity > for Entity { fn to () -> RelationDef { Relation :: Carts . def () } } + +impl Related < super :: countries :: Entity > for Entity { fn to () -> RelationDef { Relation :: Countries . def () } } + +impl Related < super :: currencies :: Entity > for Entity { fn to () -> RelationDef { Relation :: Currencies . def () } } + +impl Related < super :: gift_cards :: Entity > for Entity { fn to () -> RelationDef { Relation :: GiftCards . def () } } + +impl Related < super :: money_amounts :: Entity > for Entity { fn to () -> RelationDef { Relation :: MoneyAmounts . def () } } + +impl Related < super :: orders :: Entity > for Entity { fn to () -> RelationDef { Relation :: Orders . def () } } + +impl Related < super :: payment_collections :: Entity > for Entity { fn to () -> RelationDef { Relation :: PaymentCollections . def () } } + +impl Related < super :: shipping_options :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingOptions . def () } } + +impl Related < super :: tax_providers :: Entity > for Entity { fn to () -> RelationDef { Relation :: TaxProviders . def () } } + +impl Related < super :: tax_rates :: Entity > for Entity { fn to () -> RelationDef { Relation :: TaxRates . def () } } + +impl Related < super :: fulfillment_providers :: Entity > for Entity { fn to () -> RelationDef { super :: region_fulfillment_providers :: Relation :: FulfillmentProviders . def () } fn via () -> Option < RelationDef > { Some (super :: region_fulfillment_providers :: Relation :: Regions . def () . rev ()) } } + +impl Related < super :: payment_providers :: Entity > for Entity { fn to () -> RelationDef { super :: region_payment_providers :: Relation :: PaymentProviders . def () } fn via () -> Option < RelationDef > { Some (super :: region_payment_providers :: Relation :: Regions . def () . rev ()) } } + +impl Related < super :: discounts :: Entity > for Entity { fn to () -> RelationDef { super :: discount_regions :: Relation :: Discounts . def () } fn via () -> Option < RelationDef > { Some (super :: discount_regions :: Relation :: Regions . def () . rev ()) } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/return.rs b/crates/model/src/v4/return.rs new file mode 100644 index 0000000..5d114cd --- /dev/null +++ b/crates/model/src/v4/return.rs @@ -0,0 +1,128 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::ReturnStatuses; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "return" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub status: ReturnStatuses, + pub swap_id: Option, + pub order_id: Option, + pub shipping_data: Option, + pub refund_amount: i32, + pub received_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub metadata: Option, + pub idempotency_key: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + Status, + SwapId, + OrderId, + ShippingData, + RefundAmount, + ReceivedAt, + CreatedAt, + UpdatedAt, + Metadata, + IdempotencyKey, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Order, + ShippingMethods, + Swap, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::Status => ReturnStatuses::db_type().def(), + Self::SwapId => ColumnType::String(None).def().null().unique(), + Self::OrderId => ColumnType::String(None).def().null(), + Self::ShippingData => ColumnType::JsonBinary.def().null(), + Self::RefundAmount => ColumnType::Integer.def(), + Self::ReceivedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::IdempotencyKey => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Order => Entity::belongs_to(super::order::Entity) + .from(Column::OrderId) + .to(super::order::Column::Id) + .into(), + Self::ShippingMethods => Entity::has_one(super::shipping_methods::Entity).into(), + Self::Swap => Entity::belongs_to(super::swap::Entity) + .from(Column::SwapId) + .to(super::swap::Column::Id) + .into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Order.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ShippingMethods.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Swap.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + super::return_items::Relation::LineItems.def() + } + fn via() -> Option { + Some(super::return_items::Relation::Return.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/return_items.rs b/crates/model/src/v4/return_items.rs new file mode 100644 index 0000000..2265305 --- /dev/null +++ b/crates/model/src/v4/return_items.rs @@ -0,0 +1,31 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "return_items" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub return_id : String , pub item_id : String , pub quantity : i32 , pub is_requested : bool , pub requested_quantity : Option < i32 > , pub received_quantity : Option < i32 > , pub metadata : Option < Json > , pub reason_id : Option < String > , pub note : Option < String > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { ReturnId , ItemId , Quantity , IsRequested , RequestedQuantity , ReceivedQuantity , Metadata , ReasonId , Note , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { ReturnId , ItemId , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = (String , String) ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { LineItems , ReturnReasons , Returns , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: ReturnId => ColumnType :: String (None) . def () , Self :: ItemId => ColumnType :: String (None) . def () , Self :: Quantity => ColumnType :: Integer . def () , Self :: IsRequested => ColumnType :: Boolean . def () , Self :: RequestedQuantity => ColumnType :: Integer . def () . null () , Self :: ReceivedQuantity => ColumnType :: Integer . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: ReasonId => ColumnType :: String (None) . def () . null () , Self :: Note => ColumnType :: String (None) . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: LineItems => Entity :: belongs_to (super :: line_items :: Entity) . from (Column :: ItemId) . to (super :: line_items :: Column :: Id) . into () , Self :: ReturnReasons => Entity :: belongs_to (super :: return_reasons :: Entity) . from (Column :: ReasonId) . to (super :: return_reasons :: Column :: Id) . into () , Self :: Returns => Entity :: belongs_to (super :: returns :: Entity) . from (Column :: ReturnId) . to (super :: returns :: Column :: Id) . into () , } } } + +impl Related < super :: line_items :: Entity > for Entity { fn to () -> RelationDef { Relation :: LineItems . def () } } + +impl Related < super :: return_reasons :: Entity > for Entity { fn to () -> RelationDef { Relation :: ReturnReasons . def () } } + +impl Related < super :: returns :: Entity > for Entity { fn to () -> RelationDef { Relation :: Returns . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/return_reasons.rs b/crates/model/src/v4/return_reasons.rs new file mode 100644 index 0000000..261d73c --- /dev/null +++ b/crates/model/src/v4/return_reasons.rs @@ -0,0 +1,27 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "return_reasons" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub value : String , pub label : String , pub description : Option < String > , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , pub parent_return_reason_id : Option < String > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Value , Label , Description , CreatedAt , UpdatedAt , DeletedAt , Metadata , ParentReturnReasonId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ReturnItems , SelfRef , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Value => ColumnType :: String (None) . def () , Self :: Label => ColumnType :: String (None) . def () , Self :: Description => ColumnType :: String (None) . def () . null () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: ParentReturnReasonId => ColumnType :: String (None) . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ReturnItems => Entity :: has_many (super :: return_items :: Entity) . into () , Self :: SelfRef => Entity :: belongs_to (Entity) . from (Column :: ParentReturnReasonId) . to (Column :: Id) . into () , } } } + +impl Related < super :: return_items :: Entity > for Entity { fn to () -> RelationDef { Relation :: ReturnItems . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/returns.rs b/crates/model/src/v4/returns.rs new file mode 100644 index 0000000..61fcaef --- /dev/null +++ b/crates/model/src/v4/returns.rs @@ -0,0 +1,35 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; use super :: sea_orm_active_enums :: ReturnStatuses ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "returns" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub status : ReturnStatuses , pub swap_id : Option < String > , pub order_id : Option < String > , pub shipping_data : Option < Json > , pub refund_amount : i32 , pub received_at : Option < DateTimeWithTimeZone > , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub metadata : Option < Json > , pub idempotency_key : Option < String > , pub claim_order_id : Option < String > , pub no_notification : Option < bool > , pub location_id : Option < String > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Status , SwapId , OrderId , ShippingData , RefundAmount , ReceivedAt , CreatedAt , UpdatedAt , Metadata , IdempotencyKey , ClaimOrderId , NoNotification , LocationId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ClaimOrders , Orders , ReturnItems , ShippingMethods , Swaps , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Status => ReturnStatuses :: db_type () . def () , Self :: SwapId => ColumnType :: String (None) . def () . null () . unique () , Self :: OrderId => ColumnType :: String (None) . def () . null () , Self :: ShippingData => ColumnType :: JsonBinary . def () . null () , Self :: RefundAmount => ColumnType :: Integer . def () , Self :: ReceivedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: IdempotencyKey => ColumnType :: String (None) . def () . null () , Self :: ClaimOrderId => ColumnType :: String (None) . def () . null () . unique () , Self :: NoNotification => ColumnType :: Boolean . def () . null () , Self :: LocationId => ColumnType :: String (None) . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ClaimOrders => Entity :: belongs_to (super :: claim_orders :: Entity) . from (Column :: ClaimOrderId) . to (super :: claim_orders :: Column :: Id) . into () , Self :: Orders => Entity :: belongs_to (super :: orders :: Entity) . from (Column :: OrderId) . to (super :: orders :: Column :: Id) . into () , Self :: ReturnItems => Entity :: has_many (super :: return_items :: Entity) . into () , Self :: ShippingMethods => Entity :: has_one (super :: shipping_methods :: Entity) . into () , Self :: Swaps => Entity :: belongs_to (super :: swaps :: Entity) . from (Column :: SwapId) . to (super :: swaps :: Column :: Id) . into () , } } } + +impl Related < super :: claim_orders :: Entity > for Entity { fn to () -> RelationDef { Relation :: ClaimOrders . def () } } + +impl Related < super :: orders :: Entity > for Entity { fn to () -> RelationDef { Relation :: Orders . def () } } + +impl Related < super :: return_items :: Entity > for Entity { fn to () -> RelationDef { Relation :: ReturnItems . def () } } + +impl Related < super :: shipping_methods :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingMethods . def () } } + +impl Related < super :: swaps :: Entity > for Entity { fn to () -> RelationDef { Relation :: Swaps . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/sales_channel_locations.rs b/crates/model/src/v4/sales_channel_locations.rs new file mode 100644 index 0000000..f0e0583 --- /dev/null +++ b/crates/model/src/v4/sales_channel_locations.rs @@ -0,0 +1,25 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "sales_channel_locations" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub sales_channel_id : String , pub location_id : String , pub deleted_at : Option < DateTimeWithTimeZone > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , CreatedAt , UpdatedAt , SalesChannelId , LocationId , DeletedAt , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: SalesChannelId => ColumnType :: Text . def () , Self :: LocationId => ColumnType :: Text . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { panic ! ("No RelationDef") } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/sales_channels.rs b/crates/model/src/v4/sales_channels.rs new file mode 100644 index 0000000..52eb897 --- /dev/null +++ b/crates/model/src/v4/sales_channels.rs @@ -0,0 +1,33 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "sales_channels" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub name : String , pub description : Option < String > , pub is_disabled : bool , pub metadata : Option < Json > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , CreatedAt , UpdatedAt , DeletedAt , Name , Description , IsDisabled , Metadata , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Carts , Orders , Stores , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Name => ColumnType :: String (None) . def () , Self :: Description => ColumnType :: String (None) . def () . null () , Self :: IsDisabled => ColumnType :: Boolean . def () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Carts => Entity :: has_many (super :: carts :: Entity) . into () , Self :: Orders => Entity :: has_many (super :: orders :: Entity) . into () , Self :: Stores => Entity :: has_one (super :: stores :: Entity) . into () , } } } + +impl Related < super :: carts :: Entity > for Entity { fn to () -> RelationDef { Relation :: Carts . def () } } + +impl Related < super :: orders :: Entity > for Entity { fn to () -> RelationDef { Relation :: Orders . def () } } + +impl Related < super :: stores :: Entity > for Entity { fn to () -> RelationDef { Relation :: Stores . def () } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { super :: product_sales_channels :: Relation :: Products . def () } fn via () -> Option < RelationDef > { Some (super :: product_sales_channels :: Relation :: SalesChannels . def () . rev ()) } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/sea_orm_active_enums.rs b/crates/model/src/v4/sea_orm_active_enums.rs new file mode 100644 index 0000000..d44ded7 --- /dev/null +++ b/crates/model/src/v4/sea_orm_active_enums.rs @@ -0,0 +1,33 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "cart_types")] pub enum CartTypes { # [sea_orm (string_value = "claim")] Claim , # [sea_orm (string_value = "default")] Default , # [sea_orm (string_value = "draft_order")] DraftOrder , # [sea_orm (string_value = "payment_link")] PaymentLink , # [sea_orm (string_value = "swap")] Swap , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "claim_item_reasons")] pub enum ClaimItemReasons { # [sea_orm (string_value = "missing_item")] MissingItem , # [sea_orm (string_value = "other")] Other , # [sea_orm (string_value = "production_failure")] ProductionFailure , # [sea_orm (string_value = "wrong_item")] WrongItem , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "claim_order_fulfillment_statuses")] pub enum ClaimOrderFulfillmentStatuses { # [sea_orm (string_value = "canceled")] Canceled , # [sea_orm (string_value = "fulfilled")] Fulfilled , # [sea_orm (string_value = "not_fulfilled")] NotFulfilled , # [sea_orm (string_value = "partially_fulfilled")] PartiallyFulfilled , # [sea_orm (string_value = "partially_returned")] PartiallyReturned , # [sea_orm (string_value = "partially_shipped")] PartiallyShipped , # [sea_orm (string_value = "requires_action")] RequiresAction , # [sea_orm (string_value = "returned")] Returned , # [sea_orm (string_value = "shipped")] Shipped , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "claim_order_payment_statuses")] pub enum ClaimOrderPaymentStatuses { # [sea_orm (string_value = "na")] Na , # [sea_orm (string_value = "not_refunded")] NotRefunded , # [sea_orm (string_value = "refunded")] Refunded , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "claim_order_types")] pub enum ClaimOrderTypes { # [sea_orm (string_value = "refund")] Refund , # [sea_orm (string_value = "replace")] Replace , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "discount_condition_operators")] pub enum DiscountConditionOperators { # [sea_orm (string_value = "in")] In , # [sea_orm (string_value = "not_in")] NotIn , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "discount_condition_types")] pub enum DiscountConditionTypes { # [sea_orm (string_value = "customer_groups")] CustomerGroups , # [sea_orm (string_value = "product_collections")] ProductCollections , # [sea_orm (string_value = "product_tags")] ProductTags , # [sea_orm (string_value = "product_types")] ProductTypes , # [sea_orm (string_value = "products")] Products , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "discount_rule_allocations")] pub enum DiscountRuleAllocations { # [sea_orm (string_value = "item")] Item , # [sea_orm (string_value = "total")] Total , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "discount_rule_types")] pub enum DiscountRuleTypes { # [sea_orm (string_value = "fixed")] Fixed , # [sea_orm (string_value = "free_shipping")] FreeShipping , # [sea_orm (string_value = "percentage")] Percentage , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "draft_order_statuses")] pub enum DraftOrderStatuses { # [sea_orm (string_value = "completed")] Completed , # [sea_orm (string_value = "open")] Open , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "invite_roles")] pub enum InviteRoles { # [sea_orm (string_value = "admin")] Admin , # [sea_orm (string_value = "developer")] Developer , # [sea_orm (string_value = "member")] Member , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "order_fulfillment_statuses")] pub enum OrderFulfillmentStatuses { # [sea_orm (string_value = "canceled")] Canceled , # [sea_orm (string_value = "fulfilled")] Fulfilled , # [sea_orm (string_value = "not_fulfilled")] NotFulfilled , # [sea_orm (string_value = "partially_fulfilled")] PartiallyFulfilled , # [sea_orm (string_value = "partially_returned")] PartiallyReturned , # [sea_orm (string_value = "partially_shipped")] PartiallyShipped , # [sea_orm (string_value = "requires_action")] RequiresAction , # [sea_orm (string_value = "returned")] Returned , # [sea_orm (string_value = "shipped")] Shipped , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "order_item_change_types")] pub enum OrderItemChangeTypes { # [sea_orm (string_value = "item_add")] ItemAdd , # [sea_orm (string_value = "item_remove")] ItemRemove , # [sea_orm (string_value = "item_update")] ItemUpdate , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "order_payment_statuses")] pub enum OrderPaymentStatuses { # [sea_orm (string_value = "awaiting")] Awaiting , # [sea_orm (string_value = "canceled")] Canceled , # [sea_orm (string_value = "captured")] Captured , # [sea_orm (string_value = "not_paid")] NotPaid , # [sea_orm (string_value = "partially_refunded")] PartiallyRefunded , # [sea_orm (string_value = "refunded")] Refunded , # [sea_orm (string_value = "requires_action")] RequiresAction , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "order_statuses")] pub enum OrderStatuses { # [sea_orm (string_value = "archived")] Archived , # [sea_orm (string_value = "canceled")] Canceled , # [sea_orm (string_value = "completed")] Completed , # [sea_orm (string_value = "pending")] Pending , # [sea_orm (string_value = "requires_action")] RequiresAction , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "payment_collection_statuses")] pub enum PaymentCollectionStatuses { # [sea_orm (string_value = "authorized")] Authorized , # [sea_orm (string_value = "awaiting")] Awaiting , # [sea_orm (string_value = "canceled")] Canceled , # [sea_orm (string_value = "not_paid")] NotPaid , # [sea_orm (string_value = "partially_authorized")] PartiallyAuthorized , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "payment_collection_types")] pub enum PaymentCollectionTypes { # [sea_orm (string_value = "order_edit")] OrderEdit , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "payment_session_statuses")] pub enum PaymentSessionStatuses { # [sea_orm (string_value = "authorized")] Authorized , # [sea_orm (string_value = "canceled")] Canceled , # [sea_orm (string_value = "error")] Error , # [sea_orm (string_value = "pending")] Pending , # [sea_orm (string_value = "requires_more")] RequiresMore , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "price_list_statuses")] pub enum PriceListStatuses { # [sea_orm (string_value = "active")] Active , # [sea_orm (string_value = "draft")] Draft , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "price_list_types")] pub enum PriceListTypes { # [sea_orm (string_value = "override")] Override , # [sea_orm (string_value = "sale")] Sale , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "product_statuses")] pub enum ProductStatuses { # [sea_orm (string_value = "draft")] Draft , # [sea_orm (string_value = "proposed")] Proposed , # [sea_orm (string_value = "published")] Published , # [sea_orm (string_value = "rejected")] Rejected , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "refund_reasons")] pub enum RefundReasons { # [sea_orm (string_value = "claim")] Claim , # [sea_orm (string_value = "discount")] Discount , # [sea_orm (string_value = "other")] Other , # [sea_orm (string_value = "return")] Return , # [sea_orm (string_value = "swap")] Swap , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "return_statuses")] pub enum ReturnStatuses { # [sea_orm (string_value = "canceled")] Canceled , # [sea_orm (string_value = "received")] Received , # [sea_orm (string_value = "requested")] Requested , # [sea_orm (string_value = "requires_action")] RequiresAction , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "shipping_option_price_types")] pub enum ShippingOptionPriceTypes { # [sea_orm (string_value = "calculated")] Calculated , # [sea_orm (string_value = "flat_rate")] FlatRate , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "shipping_option_requirement_types")] pub enum ShippingOptionRequirementTypes { # [sea_orm (string_value = "max_subtotal")] MaxSubtotal , # [sea_orm (string_value = "min_subtotal")] MinSubtotal , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "shipping_profile_types")] pub enum ShippingProfileTypes { # [sea_orm (string_value = "custom")] Custom , # [sea_orm (string_value = "default")] Default , # [sea_orm (string_value = "gift_card")] GiftCard , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "swap_fulfillment_statuses")] pub enum SwapFulfillmentStatuses { # [sea_orm (string_value = "canceled")] Canceled , # [sea_orm (string_value = "fulfilled")] Fulfilled , # [sea_orm (string_value = "not_fulfilled")] NotFulfilled , # [sea_orm (string_value = "partially_shipped")] PartiallyShipped , # [sea_orm (string_value = "requires_action")] RequiresAction , # [sea_orm (string_value = "shipped")] Shipped , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "swap_payment_statuses")] pub enum SwapPaymentStatuses { # [sea_orm (string_value = "awaiting")] Awaiting , # [sea_orm (string_value = "canceled")] Canceled , # [sea_orm (string_value = "captured")] Captured , # [sea_orm (string_value = "confirmed")] Confirmed , # [sea_orm (string_value = "difference_refunded")] DifferenceRefunded , # [sea_orm (string_value = "not_paid")] NotPaid , # [sea_orm (string_value = "partially_refunded")] PartiallyRefunded , # [sea_orm (string_value = "refunded")] Refunded , # [sea_orm (string_value = "requires_action")] RequiresAction , } +# [derive (Debug , Clone , PartialEq , Eq , EnumIter , DeriveActiveEnum , Serialize , Deserialize)] # [sea_orm (rs_type = "String" , db_type = "Enum" , enum_name = "user_roles")] pub enum UserRoles { # [sea_orm (string_value = "admin")] Admin , # [sea_orm (string_value = "developer")] Developer , # [sea_orm (string_value = "member")] Member , } \ No newline at end of file diff --git a/crates/model/src/v4/shipping_method_tax_lines.rs b/crates/model/src/v4/shipping_method_tax_lines.rs new file mode 100644 index 0000000..6f3b257 --- /dev/null +++ b/crates/model/src/v4/shipping_method_tax_lines.rs @@ -0,0 +1,27 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "shipping_method_tax_lines" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Serialize , Deserialize)] pub struct Model { pub id : String , pub rate : f32 , pub name : String , pub code : Option < String > , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub metadata : Option < Json > , pub shipping_method_id : String , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Rate , Name , Code , CreatedAt , UpdatedAt , Metadata , ShippingMethodId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ShippingMethods , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Rate => ColumnType :: Float . def () , Self :: Name => ColumnType :: String (None) . def () , Self :: Code => ColumnType :: String (None) . def () . null () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: ShippingMethodId => ColumnType :: String (None) . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ShippingMethods => Entity :: belongs_to (super :: shipping_methods :: Entity) . from (Column :: ShippingMethodId) . to (super :: shipping_methods :: Column :: Id) . into () , } } } + +impl Related < super :: shipping_methods :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingMethods . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/shipping_methods.rs b/crates/model/src/v4/shipping_methods.rs new file mode 100644 index 0000000..e815a2b --- /dev/null +++ b/crates/model/src/v4/shipping_methods.rs @@ -0,0 +1,39 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "shipping_methods" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub shipping_option_id : String , pub order_id : Option < String > , pub cart_id : Option < String > , pub swap_id : Option < String > , pub return_id : Option < String > , pub price : i32 , pub data : Json , pub claim_order_id : Option < String > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , ShippingOptionId , OrderId , CartId , SwapId , ReturnId , Price , Data , ClaimOrderId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Carts , ClaimOrders , Orders , Returns , ShippingMethodTaxLines , ShippingOptions , Swaps , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: ShippingOptionId => ColumnType :: String (None) . def () , Self :: OrderId => ColumnType :: String (None) . def () . null () , Self :: CartId => ColumnType :: String (None) . def () . null () , Self :: SwapId => ColumnType :: String (None) . def () . null () , Self :: ReturnId => ColumnType :: String (None) . def () . null () . unique () , Self :: Price => ColumnType :: Integer . def () , Self :: Data => ColumnType :: JsonBinary . def () , Self :: ClaimOrderId => ColumnType :: String (None) . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Carts => Entity :: belongs_to (super :: carts :: Entity) . from (Column :: CartId) . to (super :: carts :: Column :: Id) . into () , Self :: ClaimOrders => Entity :: belongs_to (super :: claim_orders :: Entity) . from (Column :: ClaimOrderId) . to (super :: claim_orders :: Column :: Id) . into () , Self :: Orders => Entity :: belongs_to (super :: orders :: Entity) . from (Column :: OrderId) . to (super :: orders :: Column :: Id) . into () , Self :: Returns => Entity :: belongs_to (super :: returns :: Entity) . from (Column :: ReturnId) . to (super :: returns :: Column :: Id) . into () , Self :: ShippingMethodTaxLines => Entity :: has_many (super :: shipping_method_tax_lines :: Entity) . into () , Self :: ShippingOptions => Entity :: belongs_to (super :: shipping_options :: Entity) . from (Column :: ShippingOptionId) . to (super :: shipping_options :: Column :: Id) . into () , Self :: Swaps => Entity :: belongs_to (super :: swaps :: Entity) . from (Column :: SwapId) . to (super :: swaps :: Column :: Id) . into () , } } } + +impl Related < super :: carts :: Entity > for Entity { fn to () -> RelationDef { Relation :: Carts . def () } } + +impl Related < super :: claim_orders :: Entity > for Entity { fn to () -> RelationDef { Relation :: ClaimOrders . def () } } + +impl Related < super :: orders :: Entity > for Entity { fn to () -> RelationDef { Relation :: Orders . def () } } + +impl Related < super :: returns :: Entity > for Entity { fn to () -> RelationDef { Relation :: Returns . def () } } + +impl Related < super :: shipping_method_tax_lines :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingMethodTaxLines . def () } } + +impl Related < super :: shipping_options :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingOptions . def () } } + +impl Related < super :: swaps :: Entity > for Entity { fn to () -> RelationDef { Relation :: Swaps . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/shipping_option_requirements.rs b/crates/model/src/v4/shipping_option_requirements.rs new file mode 100644 index 0000000..5061031 --- /dev/null +++ b/crates/model/src/v4/shipping_option_requirements.rs @@ -0,0 +1,27 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; use super :: sea_orm_active_enums :: ShippingOptionRequirementTypes ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "shipping_option_requirements" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub shipping_option_id : String , pub r#type : ShippingOptionRequirementTypes , pub amount : i32 , pub deleted_at : Option < DateTimeWithTimeZone > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , ShippingOptionId , Type , Amount , DeletedAt , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ShippingOptions , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: ShippingOptionId => ColumnType :: String (None) . def () , Self :: Type => ShippingOptionRequirementTypes :: db_type () . def () , Self :: Amount => ColumnType :: Integer . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ShippingOptions => Entity :: belongs_to (super :: shipping_options :: Entity) . from (Column :: ShippingOptionId) . to (super :: shipping_options :: Column :: Id) . into () , } } } + +impl Related < super :: shipping_options :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingOptions . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/shipping_options.rs b/crates/model/src/v4/shipping_options.rs new file mode 100644 index 0000000..beabfdd --- /dev/null +++ b/crates/model/src/v4/shipping_options.rs @@ -0,0 +1,39 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; use super :: sea_orm_active_enums :: ShippingOptionPriceTypes ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "shipping_options" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub name : String , pub region_id : String , pub profile_id : String , pub provider_id : String , pub price_type : ShippingOptionPriceTypes , pub amount : Option < i32 > , pub is_return : bool , pub data : Json , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , pub admin_only : bool , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Name , RegionId , ProfileId , ProviderId , PriceType , Amount , IsReturn , Data , CreatedAt , UpdatedAt , DeletedAt , Metadata , AdminOnly , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { CustomShippingOptions , FulfillmentProviders , Regions , ShippingMethods , ShippingOptionRequirements , ShippingProfiles , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Name => ColumnType :: String (None) . def () , Self :: RegionId => ColumnType :: String (None) . def () , Self :: ProfileId => ColumnType :: String (None) . def () , Self :: ProviderId => ColumnType :: String (None) . def () , Self :: PriceType => ShippingOptionPriceTypes :: db_type () . def () , Self :: Amount => ColumnType :: Integer . def () . null () , Self :: IsReturn => ColumnType :: Boolean . def () , Self :: Data => ColumnType :: JsonBinary . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: AdminOnly => ColumnType :: Boolean . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: CustomShippingOptions => Entity :: has_many (super :: custom_shipping_options :: Entity) . into () , Self :: FulfillmentProviders => Entity :: belongs_to (super :: fulfillment_providers :: Entity) . from (Column :: ProviderId) . to (super :: fulfillment_providers :: Column :: Id) . into () , Self :: Regions => Entity :: belongs_to (super :: regions :: Entity) . from (Column :: RegionId) . to (super :: regions :: Column :: Id) . into () , Self :: ShippingMethods => Entity :: has_many (super :: shipping_methods :: Entity) . into () , Self :: ShippingOptionRequirements => Entity :: has_many (super :: shipping_option_requirements :: Entity) . into () , Self :: ShippingProfiles => Entity :: belongs_to (super :: shipping_profiles :: Entity) . from (Column :: ProfileId) . to (super :: shipping_profiles :: Column :: Id) . into () , } } } + +impl Related < super :: custom_shipping_options :: Entity > for Entity { fn to () -> RelationDef { Relation :: CustomShippingOptions . def () } } + +impl Related < super :: fulfillment_providers :: Entity > for Entity { fn to () -> RelationDef { Relation :: FulfillmentProviders . def () } } + +impl Related < super :: regions :: Entity > for Entity { fn to () -> RelationDef { Relation :: Regions . def () } } + +impl Related < super :: shipping_methods :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingMethods . def () } } + +impl Related < super :: shipping_option_requirements :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingOptionRequirements . def () } } + +impl Related < super :: shipping_profiles :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingProfiles . def () } } + +impl Related < super :: tax_rates :: Entity > for Entity { fn to () -> RelationDef { super :: shipping_tax_rates :: Relation :: TaxRates . def () } fn via () -> Option < RelationDef > { Some (super :: shipping_tax_rates :: Relation :: ShippingOptions . def () . rev ()) } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/shipping_profiles.rs b/crates/model/src/v4/shipping_profiles.rs new file mode 100644 index 0000000..ca8924f --- /dev/null +++ b/crates/model/src/v4/shipping_profiles.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; use super :: sea_orm_active_enums :: ShippingProfileTypes ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "shipping_profiles" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub name : String , pub r#type : ShippingProfileTypes , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Name , Type , CreatedAt , UpdatedAt , DeletedAt , Metadata , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Products , ShippingOptions , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Name => ColumnType :: String (None) . def () , Self :: Type => ShippingProfileTypes :: db_type () . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Products => Entity :: has_many (super :: products :: Entity) . into () , Self :: ShippingOptions => Entity :: has_many (super :: shipping_options :: Entity) . into () , } } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { Relation :: Products . def () } } + +impl Related < super :: shipping_options :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingOptions . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/shipping_tax_rates.rs b/crates/model/src/v4/shipping_tax_rates.rs new file mode 100644 index 0000000..8b1f532 --- /dev/null +++ b/crates/model/src/v4/shipping_tax_rates.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "shipping_tax_rates" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub shipping_option_id : String , pub rate_id : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub metadata : Option < Json > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { ShippingOptionId , RateId , CreatedAt , UpdatedAt , Metadata , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { ShippingOptionId , RateId , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = (String , String) ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { ShippingOptions , TaxRates , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: ShippingOptionId => ColumnType :: String (None) . def () , Self :: RateId => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: ShippingOptions => Entity :: belongs_to (super :: shipping_options :: Entity) . from (Column :: ShippingOptionId) . to (super :: shipping_options :: Column :: Id) . into () , Self :: TaxRates => Entity :: belongs_to (super :: tax_rates :: Entity) . from (Column :: RateId) . to (super :: tax_rates :: Column :: Id) . into () , } } } + +impl Related < super :: shipping_options :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingOptions . def () } } + +impl Related < super :: tax_rates :: Entity > for Entity { fn to () -> RelationDef { Relation :: TaxRates . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/staged_job.rs b/crates/model/src/v4/staged_job.rs new file mode 100644 index 0000000..e505a96 --- /dev/null +++ b/crates/model/src/v4/staged_job.rs @@ -0,0 +1,61 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "staged_job" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub event_name: String, + pub data: Json, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + EventName, + Data, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::EventName => ColumnType::String(None).def(), + Self::Data => ColumnType::JsonBinary.def(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/staged_jobs.rs b/crates/model/src/v4/staged_jobs.rs new file mode 100644 index 0000000..c61dfcc --- /dev/null +++ b/crates/model/src/v4/staged_jobs.rs @@ -0,0 +1,25 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "staged_jobs" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub event_name : String , pub data : Json , pub options : Json , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , EventName , Data , Options , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: EventName => ColumnType :: String (None) . def () , Self :: Data => ColumnType :: JsonBinary . def () , Self :: Options => ColumnType :: JsonBinary . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { panic ! ("No RelationDef") } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/store_currencies.rs b/crates/model/src/v4/store_currencies.rs new file mode 100644 index 0000000..f008d89 --- /dev/null +++ b/crates/model/src/v4/store_currencies.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "store_currencies" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub store_id : String , pub currency_code : String , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { StoreId , CurrencyCode , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { StoreId , CurrencyCode , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = (String , String) ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Currencies , Stores , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: StoreId => ColumnType :: String (None) . def () , Self :: CurrencyCode => ColumnType :: String (None) . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Currencies => Entity :: belongs_to (super :: currencies :: Entity) . from (Column :: CurrencyCode) . to (super :: currencies :: Column :: Code) . into () , Self :: Stores => Entity :: belongs_to (super :: stores :: Entity) . from (Column :: StoreId) . to (super :: stores :: Column :: Id) . into () , } } } + +impl Related < super :: currencies :: Entity > for Entity { fn to () -> RelationDef { Relation :: Currencies . def () } } + +impl Related < super :: stores :: Entity > for Entity { fn to () -> RelationDef { Relation :: Stores . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/stores.rs b/crates/model/src/v4/stores.rs new file mode 100644 index 0000000..f3c25c2 --- /dev/null +++ b/crates/model/src/v4/stores.rs @@ -0,0 +1,29 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "stores" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub name : String , pub default_currency_code : String , pub swap_link_template : Option < String > , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub metadata : Option < Json > , pub payment_link_template : Option < String > , pub invite_link_template : Option < String > , pub default_sales_channel_id : Option < String > , pub default_location_id : Option < String > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Name , DefaultCurrencyCode , SwapLinkTemplate , CreatedAt , UpdatedAt , Metadata , PaymentLinkTemplate , InviteLinkTemplate , DefaultSalesChannelId , DefaultLocationId , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Currencies , SalesChannels , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Name => ColumnType :: String (None) . def () , Self :: DefaultCurrencyCode => ColumnType :: String (None) . def () , Self :: SwapLinkTemplate => ColumnType :: String (None) . def () . null () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: PaymentLinkTemplate => ColumnType :: String (None) . def () . null () , Self :: InviteLinkTemplate => ColumnType :: String (None) . def () . null () , Self :: DefaultSalesChannelId => ColumnType :: String (None) . def () . null () . unique () , Self :: DefaultLocationId => ColumnType :: String (None) . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Currencies => Entity :: belongs_to (super :: currencies :: Entity) . from (Column :: DefaultCurrencyCode) . to (super :: currencies :: Column :: Code) . into () , Self :: SalesChannels => Entity :: belongs_to (super :: sales_channels :: Entity) . from (Column :: DefaultSalesChannelId) . to (super :: sales_channels :: Column :: Id) . into () , } } } + +impl Related < super :: sales_channels :: Entity > for Entity { fn to () -> RelationDef { Relation :: SalesChannels . def () } } + +impl Related < super :: currencies :: Entity > for Entity { fn to () -> RelationDef { super :: store_currencies :: Relation :: Currencies . def () } fn via () -> Option < RelationDef > { Some (super :: store_currencies :: Relation :: Stores . def () . rev ()) } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/swap.rs b/crates/model/src/v4/swap.rs new file mode 100644 index 0000000..1db06bc --- /dev/null +++ b/crates/model/src/v4/swap.rs @@ -0,0 +1,168 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +use super::sea_orm_active_enums::{SwapFulfillmentStatuses, SwapPaymentStatuses}; + +#[derive(Copy, Clone, Default, Debug, DeriveEntity)] +pub struct Entity; + +impl EntityName for Entity { + fn table_name(&self) -> &str { + "swap" + } +} + +#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] +pub struct Model { + pub id: String, + pub fulfillment_status: SwapFulfillmentStatuses, + pub payment_status: SwapPaymentStatuses, + pub order_id: String, + pub difference_due: Option, + pub shipping_address_id: Option, + pub cart_id: Option, + pub confirmed_at: Option, + pub created_at: DateTimeWithTimeZone, + pub updated_at: DateTimeWithTimeZone, + pub deleted_at: Option, + pub metadata: Option, + pub idempotency_key: Option, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] +pub enum Column { + Id, + FulfillmentStatus, + PaymentStatus, + OrderId, + DifferenceDue, + ShippingAddressId, + CartId, + ConfirmedAt, + CreatedAt, + UpdatedAt, + DeletedAt, + Metadata, + IdempotencyKey, +} + +#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] +pub enum PrimaryKey { + Id, +} + +impl PrimaryKeyTrait for PrimaryKey { + type ValueType = String; + fn auto_increment() -> bool { + false + } +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation { + Addresses, + Cart, + Fulfillments, + LineItems, + Order, + Payments, + Return, + ShippingMethods, +} + +impl ColumnTrait for Column { + type EntityName = Entity; + fn def(&self) -> ColumnDef { + match self { + Self::Id => ColumnType::String(None).def(), + Self::FulfillmentStatus => SwapFulfillmentStatuses::db_type().def(), + Self::PaymentStatus => SwapPaymentStatuses::db_type().def(), + Self::OrderId => ColumnType::String(None).def(), + Self::DifferenceDue => ColumnType::Integer.def().null(), + Self::ShippingAddressId => ColumnType::String(None).def().null(), + Self::CartId => ColumnType::String(None).def().null().unique(), + Self::ConfirmedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), + Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), + Self::Metadata => ColumnType::JsonBinary.def().null(), + Self::IdempotencyKey => ColumnType::String(None).def().null(), + } + } +} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + match self { + Self::Addresses => Entity::belongs_to(super::addresses::Entity) + .from(Column::ShippingAddressId) + .to(super::addresses::Column::Id) + .into(), + Self::Cart => Entity::belongs_to(super::cart::Entity) + .from(Column::CartId) + .to(super::cart::Column::Id) + .into(), + Self::Fulfillments => Entity::has_many(super::fulfillments::Entity).into(), + Self::LineItems => Entity::has_many(super::line_items::Entity).into(), + Self::Order => Entity::belongs_to(super::order::Entity) + .from(Column::OrderId) + .to(super::order::Column::Id) + .into(), + Self::Payments => Entity::has_one(super::payments::Entity).into(), + Self::Return => Entity::has_one(super::r#return::Entity).into(), + Self::ShippingMethods => Entity::has_many(super::shipping_methods::Entity).into(), + } + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Addresses.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Cart.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Fulfillments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::LineItems.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Order.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Payments.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Return.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::ShippingMethods.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/model/src/v4/swaps.rs b/crates/model/src/v4/swaps.rs new file mode 100644 index 0000000..be9a05a --- /dev/null +++ b/crates/model/src/v4/swaps.rs @@ -0,0 +1,41 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; use super :: sea_orm_active_enums :: SwapFulfillmentStatuses ; use super :: sea_orm_active_enums :: SwapPaymentStatuses ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "swaps" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub fulfillment_status : SwapFulfillmentStatuses , pub payment_status : SwapPaymentStatuses , pub order_id : String , pub difference_due : Option < i32 > , pub shipping_address_id : Option < String > , pub cart_id : Option < String > , pub confirmed_at : Option < DateTimeWithTimeZone > , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , pub idempotency_key : Option < String > , pub no_notification : Option < bool > , pub canceled_at : Option < DateTimeWithTimeZone > , pub allow_backorder : bool , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , FulfillmentStatus , PaymentStatus , OrderId , DifferenceDue , ShippingAddressId , CartId , ConfirmedAt , CreatedAt , UpdatedAt , DeletedAt , Metadata , IdempotencyKey , NoNotification , CanceledAt , AllowBackorder , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Addresses , Carts , Fulfillments , LineItems , Orders , Payments , Returns , ShippingMethods , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: FulfillmentStatus => SwapFulfillmentStatuses :: db_type () . def () , Self :: PaymentStatus => SwapPaymentStatuses :: db_type () . def () , Self :: OrderId => ColumnType :: String (None) . def () , Self :: DifferenceDue => ColumnType :: Integer . def () . null () , Self :: ShippingAddressId => ColumnType :: String (None) . def () . null () , Self :: CartId => ColumnType :: String (None) . def () . null () . unique () , Self :: ConfirmedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: IdempotencyKey => ColumnType :: String (None) . def () . null () , Self :: NoNotification => ColumnType :: Boolean . def () . null () , Self :: CanceledAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: AllowBackorder => ColumnType :: Boolean . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Addresses => Entity :: belongs_to (super :: addresses :: Entity) . from (Column :: ShippingAddressId) . to (super :: addresses :: Column :: Id) . into () , Self :: Carts => Entity :: belongs_to (super :: carts :: Entity) . from (Column :: CartId) . to (super :: carts :: Column :: Id) . into () , Self :: Fulfillments => Entity :: has_many (super :: fulfillments :: Entity) . into () , Self :: LineItems => Entity :: has_many (super :: line_items :: Entity) . into () , Self :: Orders => Entity :: belongs_to (super :: orders :: Entity) . from (Column :: OrderId) . to (super :: orders :: Column :: Id) . into () , Self :: Payments => Entity :: has_one (super :: payments :: Entity) . into () , Self :: Returns => Entity :: has_one (super :: returns :: Entity) . into () , Self :: ShippingMethods => Entity :: has_many (super :: shipping_methods :: Entity) . into () , } } } + +impl Related < super :: addresses :: Entity > for Entity { fn to () -> RelationDef { Relation :: Addresses . def () } } + +impl Related < super :: carts :: Entity > for Entity { fn to () -> RelationDef { Relation :: Carts . def () } } + +impl Related < super :: fulfillments :: Entity > for Entity { fn to () -> RelationDef { Relation :: Fulfillments . def () } } + +impl Related < super :: line_items :: Entity > for Entity { fn to () -> RelationDef { Relation :: LineItems . def () } } + +impl Related < super :: orders :: Entity > for Entity { fn to () -> RelationDef { Relation :: Orders . def () } } + +impl Related < super :: payments :: Entity > for Entity { fn to () -> RelationDef { Relation :: Payments . def () } } + +impl Related < super :: returns :: Entity > for Entity { fn to () -> RelationDef { Relation :: Returns . def () } } + +impl Related < super :: shipping_methods :: Entity > for Entity { fn to () -> RelationDef { Relation :: ShippingMethods . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/tax_providers.rs b/crates/model/src/v4/tax_providers.rs new file mode 100644 index 0000000..2cdc479 --- /dev/null +++ b/crates/model/src/v4/tax_providers.rs @@ -0,0 +1,27 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "tax_providers" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub is_installed : bool , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , IsInstalled , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Regions , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: IsInstalled => ColumnType :: Boolean . def () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Regions => Entity :: has_many (super :: regions :: Entity) . into () , } } } + +impl Related < super :: regions :: Entity > for Entity { fn to () -> RelationDef { Relation :: Regions . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/tax_rates.rs b/crates/model/src/v4/tax_rates.rs new file mode 100644 index 0000000..b66ab60 --- /dev/null +++ b/crates/model/src/v4/tax_rates.rs @@ -0,0 +1,33 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "tax_rates" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Serialize , Deserialize)] pub struct Model { pub id : String , pub rate : Option < f32 > , pub code : Option < String > , pub name : String , pub region_id : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub metadata : Option < Json > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Rate , Code , Name , RegionId , CreatedAt , UpdatedAt , Metadata , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Regions , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Rate => ColumnType :: Float . def () . null () , Self :: Code => ColumnType :: String (None) . def () . null () , Self :: Name => ColumnType :: String (None) . def () , Self :: RegionId => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Regions => Entity :: belongs_to (super :: regions :: Entity) . from (Column :: RegionId) . to (super :: regions :: Column :: Id) . into () , } } } + +impl Related < super :: regions :: Entity > for Entity { fn to () -> RelationDef { Relation :: Regions . def () } } + +impl Related < super :: products :: Entity > for Entity { fn to () -> RelationDef { super :: product_tax_rates :: Relation :: Products . def () } fn via () -> Option < RelationDef > { Some (super :: product_tax_rates :: Relation :: TaxRates . def () . rev ()) } } + +impl Related < super :: product_types :: Entity > for Entity { fn to () -> RelationDef { super :: product_type_tax_rates :: Relation :: ProductTypes . def () } fn via () -> Option < RelationDef > { Some (super :: product_type_tax_rates :: Relation :: TaxRates . def () . rev ()) } } + +impl Related < super :: shipping_options :: Entity > for Entity { fn to () -> RelationDef { super :: shipping_tax_rates :: Relation :: ShippingOptions . def () } fn via () -> Option < RelationDef > { Some (super :: shipping_tax_rates :: Relation :: TaxRates . def () . rev ()) } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/tracking_links.rs b/crates/model/src/v4/tracking_links.rs new file mode 100644 index 0000000..46e1821 --- /dev/null +++ b/crates/model/src/v4/tracking_links.rs @@ -0,0 +1,27 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "tracking_links" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub url : Option < String > , pub tracking_number : String , pub fulfillment_id : String , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , pub idempotency_key : Option < String > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Url , TrackingNumber , FulfillmentId , CreatedAt , UpdatedAt , DeletedAt , Metadata , IdempotencyKey , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { Fulfillments , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Url => ColumnType :: String (None) . def () . null () , Self :: TrackingNumber => ColumnType :: String (None) . def () , Self :: FulfillmentId => ColumnType :: String (None) . def () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: IdempotencyKey => ColumnType :: String (None) . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: Fulfillments => Entity :: belongs_to (super :: fulfillments :: Entity) . from (Column :: FulfillmentId) . to (super :: fulfillments :: Column :: Id) . into () , } } } + +impl Related < super :: fulfillments :: Entity > for Entity { fn to () -> RelationDef { Relation :: Fulfillments . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/model/src/v4/users.rs b/crates/model/src/v4/users.rs new file mode 100644 index 0000000..fca67e5 --- /dev/null +++ b/crates/model/src/v4/users.rs @@ -0,0 +1,27 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 + + + +use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ; use super :: sea_orm_active_enums :: UserRoles ; + +# [derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ; + +impl EntityName for Entity { fn table_name (& self) -> & str { "users" } } + +# [derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub id : String , pub email : String , pub first_name : Option < String > , pub last_name : Option < String > , pub password_hash : Option < String > , pub api_token : Option < String > , pub created_at : DateTimeWithTimeZone , pub updated_at : DateTimeWithTimeZone , pub deleted_at : Option < DateTimeWithTimeZone > , pub metadata : Option < Json > , pub role : Option < UserRoles > , } + +# [derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { Id , Email , FirstName , LastName , PasswordHash , ApiToken , CreatedAt , UpdatedAt , DeletedAt , Metadata , Role , } + +# [derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { Id , } + +impl PrimaryKeyTrait for PrimaryKey { type ValueType = String ; fn auto_increment () -> bool { false } } + +# [derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { BatchJobs , } + +impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: Id => ColumnType :: String (None) . def () , Self :: Email => ColumnType :: String (None) . def () , Self :: FirstName => ColumnType :: String (None) . def () . null () , Self :: LastName => ColumnType :: String (None) . def () . null () , Self :: PasswordHash => ColumnType :: String (None) . def () . null () , Self :: ApiToken => ColumnType :: String (None) . def () . null () , Self :: CreatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: UpdatedAt => ColumnType :: TimestampWithTimeZone . def () , Self :: DeletedAt => ColumnType :: TimestampWithTimeZone . def () . null () , Self :: Metadata => ColumnType :: JsonBinary . def () . null () , Self :: Role => UserRoles :: db_type () . def () . null () , } } } + +impl RelationTrait for Relation { fn def (& self) -> RelationDef { match self { Self :: BatchJobs => Entity :: has_many (super :: batch_jobs :: Entity) . into () , } } } + +impl Related < super :: batch_jobs :: Entity > for Entity { fn to () -> RelationDef { Relation :: BatchJobs . def () } } + +impl ActiveModelBehavior for ActiveModel { } \ No newline at end of file diff --git a/crates/payment-adapter/Cargo.toml b/crates/payment-adapter/Cargo.toml index e2a6c9e..444e40c 100644 --- a/crates/payment-adapter/Cargo.toml +++ b/crates/payment-adapter/Cargo.toml @@ -4,15 +4,15 @@ version = "0.1.0" edition = "2021" [dependencies] +actix-web = { version = "4.3.1" } +async-trait = { version = "0.1.68" } +chrono = { version = "0.4.24" } config = { path = "../config", default-features = false, features = [] } futures = { version = "0" } model = { path = "../model" } serde = { version = "1", features = ['derive'] } thiserror = { version = "1" } -tracing = { version = "0" } -uuid = { version = "1", features = ['v4'] } -async-trait = { version = "0.1.68" } -chrono = { version = "0.4.24" } toml = { version = "0.7.3" } +tracing = { version = "0" } traitcast = { version = "0.5.0" } -actix-web = { version = "4.3.1" } +uuid = { version = "1", features = ['v4'] } diff --git a/crates/payment-adapter/src/lib.rs b/crates/payment-adapter/src/lib.rs index 3f34e57..ab3314d 100644 --- a/crates/payment-adapter/src/lib.rs +++ b/crates/payment-adapter/src/lib.rs @@ -140,7 +140,9 @@ pub type PResult = Result; #[async_trait::async_trait] pub trait PaymentAdapter { - async fn new(config: PluginConfig) -> Self; + async fn new(config: PluginConfig) -> Self + where + Self: Sized; fn identifier(&self) -> &'static str; @@ -182,7 +184,7 @@ pub trait PaymentAdapter { * Capture an existing session */ async fn capture_payment( - &mut self, + &self, payment_session_data: &mut Box, ) -> PResult<()>; diff --git a/crates/payment-pay-u/Cargo.lock b/crates/payment-pay-u-plugin/Cargo.lock similarity index 100% rename from crates/payment-pay-u/Cargo.lock rename to crates/payment-pay-u-plugin/Cargo.lock diff --git a/crates/payment-pay-u/Cargo.toml b/crates/payment-pay-u-plugin/Cargo.toml similarity index 89% rename from crates/payment-pay-u/Cargo.toml rename to crates/payment-pay-u-plugin/Cargo.toml index 49a2f25..87d55a6 100644 --- a/crates/payment-pay-u/Cargo.toml +++ b/crates/payment-pay-u-plugin/Cargo.toml @@ -6,17 +6,17 @@ edition = "2021" [lib] crate-type = ['dylib'] -[build] -rustflags = ["-C", "prefer-dynamic", "-C", "rpath"] +#[build] +#rustflags = ["-C", "prefer-dynamic", "-C", "rpath"] [dependencies] +async-trait = { version = "0.1.68" } bincode = { version = "1" } -tracing = { version = "0" } chrono = { version = "0", features = ['alloc', 'wasmbind'] } common_macros = { version = "0" } -payment-adapter = { path = "../payment-adapter" } fulfillment_adapter = { path = "../fulfillment_adapter" } +payment-adapter = { path = "../payment-adapter" } serde = { version = "1", features = ['derive'] } serde_json = { version = "1" } -async-trait = { version = "0.1.68" } thiserror = { version = "1.0.40" } +tracing = { version = "0" } diff --git a/crates/payment-pay-u/src/credit.rs b/crates/payment-pay-u-plugin/src/credit.rs similarity index 100% rename from crates/payment-pay-u/src/credit.rs rename to crates/payment-pay-u-plugin/src/credit.rs diff --git a/crates/payment-pay-u/src/deserialize.rs b/crates/payment-pay-u-plugin/src/deserialize.rs similarity index 100% rename from crates/payment-pay-u/src/deserialize.rs rename to crates/payment-pay-u-plugin/src/deserialize.rs diff --git a/crates/payment-pay-u/src/lib.rs b/crates/payment-pay-u-plugin/src/lib.rs similarity index 99% rename from crates/payment-pay-u/src/lib.rs rename to crates/payment-pay-u-plugin/src/lib.rs index b82ec64..bcfe2cc 100644 --- a/crates/payment-pay-u/src/lib.rs +++ b/crates/payment-pay-u-plugin/src/lib.rs @@ -67,7 +67,7 @@ pub struct PayUConfig { #[async_trait::async_trait] impl PaymentAdapter for PayUPayment { - async fn new(config: Config) -> Self { + async fn new(config: PluginConfig) -> Self { let config: PayUConfig = config.config().expect("Malformed Stripe PayU config"); Self { sandbox: config.sandbox, @@ -114,7 +114,7 @@ impl PaymentAdapter for PayUPayment { } async fn capture_payment( - &mut self, + &self, payment_session_data: &mut Box, ) -> PResult<()> { todo!() diff --git a/crates/payment-pay-u/src/model.rs b/crates/payment-pay-u-plugin/src/model.rs similarity index 100% rename from crates/payment-pay-u/src/model.rs rename to crates/payment-pay-u-plugin/src/model.rs diff --git a/crates/payment-pay-u/src/notify.rs b/crates/payment-pay-u-plugin/src/notify.rs similarity index 100% rename from crates/payment-pay-u/src/notify.rs rename to crates/payment-pay-u-plugin/src/notify.rs diff --git a/crates/payment-pay-u/src/req.rs b/crates/payment-pay-u-plugin/src/req.rs similarity index 100% rename from crates/payment-pay-u/src/req.rs rename to crates/payment-pay-u-plugin/src/req.rs diff --git a/crates/payment-pay-u/src/res.rs b/crates/payment-pay-u-plugin/src/res.rs similarity index 100% rename from crates/payment-pay-u/src/res.rs rename to crates/payment-pay-u-plugin/src/res.rs diff --git a/crates/payment-pay-u/src/serialize.rs b/crates/payment-pay-u-plugin/src/serialize.rs similarity index 100% rename from crates/payment-pay-u/src/serialize.rs rename to crates/payment-pay-u-plugin/src/serialize.rs diff --git a/crates/payment-stripe/Cargo.toml b/crates/payment-stripe-plugin/Cargo.toml similarity index 65% rename from crates/payment-stripe/Cargo.toml rename to crates/payment-stripe-plugin/Cargo.toml index ba5d667..6e08295 100644 --- a/crates/payment-stripe/Cargo.toml +++ b/crates/payment-stripe-plugin/Cargo.toml @@ -6,32 +6,15 @@ edition = "2021" [lib] crate-type = ['dylib'] -#[lib] -#crate-type = ['dylib'] -#name = "stripe-common" -#path = "./src/lib.rs" -# -#[lib] -#crate-type = ['dylib'] -#name = "stripe-adapters" -#path = "./src/adapters.rs" -# -#[lib] -#crate-type = ['dylib'] -#name = "stripe-web" -#path = "./src/web.rs" - -#[build] -#rustflags = ["-C", "prefer-dynamic", "-C", "rpath"] - [dependencies] -payment-adapter = { path = "../payment-adapter" } +actix-web = { version = "4.3.1" } +async-stripe = { version = "0.21.0", features = ['tokio', 'async', 'runtime-tokio-hyper'] } +async-trait = { version = "0.1.68" } +derive_more = { version = "0.99.17" } fulfillment_adapter = { path = "../fulfillment_adapter" } +payment-adapter = { path = "../payment-adapter" } +plugin-api = { workspace = true } +serde = { version = "1.0.162", features = ['derive'] } +thiserror = { version = "1.0.40" } tokio = { version = "1.27.0" } tracing = { version = "0.1.37" } -async-trait = { version = "0.1.68" } -serde = { version = "1.0.162", features = ['derive'] } -derive_more = { version = "0.99.17" } -async-stripe = { version = "0.21.0", features = ['tokio', 'async', 'runtime-tokio-hyper'] } -actix-web = { version = "4.3.1" } -thiserror = { version = "1.0.40" } diff --git a/crates/payment-stripe/src/lib.rs b/crates/payment-stripe-plugin/src/lib.rs similarity index 64% rename from crates/payment-stripe/src/lib.rs rename to crates/payment-stripe-plugin/src/lib.rs index 8fd3a96..08aea5f 100644 --- a/crates/payment-stripe/src/lib.rs +++ b/crates/payment-stripe-plugin/src/lib.rs @@ -2,14 +2,19 @@ use std::str::FromStr; +use async_trait::async_trait; use fulfillment_adapter::*; use payment_adapter::*; +use plugin_api::{AppConfig, PaymentMethodRegister, Plugin, PluginType}; use tracing::warn; +use crate::przelewy_24::{StripePrzelewy24, PRZELEWY_24_NAME}; + mod przelewy_24; mod routes; static PLUGIN_NAME: &'static str = "stripe-adapter"; +pub static METADATA_ADAPTER_NAME: &str = "adapter-name"; #[derive(Debug, serde::Deserialize, serde::Serialize)] pub enum CaptureMethod { @@ -17,13 +22,14 @@ pub enum CaptureMethod { Manual, } -#[derive(Debug, Copy, Clone, serde::Deserialize, serde::Serialize)] +#[derive(Debug, Default, Copy, Clone, serde::Deserialize, serde::Serialize)] pub enum SetupFutureUsage { + #[default] OnSession, OffSession, } -#[derive(Debug, serde::Deserialize, serde::Serialize)] +#[derive(Debug, Default, serde::Deserialize, serde::Serialize)] pub struct StripeConfig { pub api_key: String, pub client: String, @@ -87,7 +93,13 @@ impl StripeCustomerMetadata for Customer { } #[derive(Debug, derive_more::Deref, derive_more::DerefMut)] -struct Intent(::stripe::PaymentIntent); +pub struct Intent(::stripe::PaymentIntent); + +impl Intent { + pub fn new(intent: ::stripe::PaymentIntent) -> Self { + Self(intent) + } +} impl PaymentSessionData for Intent { fn id(&self) -> Option { @@ -97,14 +109,41 @@ impl PaymentSessionData for Intent { pub struct StripePlugin { pub config: StripeConfig, + przelewy24_config: Option, } +#[async_trait] impl Plugin for StripePlugin { + fn plugin_type() -> PluginType + where + Self: Sized, + { + PluginType::Payment + } + fn name(&self) -> &'static str { PLUGIN_NAME } - fn mount(&self, config: &mut actix_web::web::ServiceConfig) { - config.service(routes::stripe_hooks); + async fn initialize(app_config: &AppConfig) -> Self + where + Self: Sized, + { + Self { + config: app_config + .plugin_config(PLUGIN_NAME) + .unwrap_or_default() + .config() + .unwrap_or_default(), + przelewy24_config: app_config.plugin_config(PRZELEWY_24_NAME), + } + } + + async fn register_payment_methods(&mut self, methods: &'static mut PaymentMethodRegister) { + { + let plugin = + StripePrzelewy24::new(self.przelewy24_config.clone().unwrap_or_default()).await; + methods.register(true, Box::new(plugin)); + } } } diff --git a/crates/payment-stripe/src/lib/adapters.rs b/crates/payment-stripe-plugin/src/lib/adapters.rs similarity index 100% rename from crates/payment-stripe/src/lib/adapters.rs rename to crates/payment-stripe-plugin/src/lib/adapters.rs diff --git a/crates/payment-stripe/src/lib/web.rs b/crates/payment-stripe-plugin/src/lib/web.rs similarity index 100% rename from crates/payment-stripe/src/lib/web.rs rename to crates/payment-stripe-plugin/src/lib/web.rs diff --git a/crates/payment-stripe/src/przelewy_24.rs b/crates/payment-stripe-plugin/src/przelewy_24.rs similarity index 94% rename from crates/payment-stripe/src/przelewy_24.rs rename to crates/payment-stripe-plugin/src/przelewy_24.rs index 85b6acf..e2e481b 100644 --- a/crates/payment-stripe/src/przelewy_24.rs +++ b/crates/payment-stripe-plugin/src/przelewy_24.rs @@ -2,30 +2,31 @@ use std::collections::HashMap; use std::str::FromStr; use payment_adapter::{ - session_mut_ref, session_ref, Amount, AnyData, Config, CustomerMetadata, PError, PResult, + session_mut_ref, session_ref, Amount, AnyData, CustomerMetadata, PError, PResult, PaymentAdapter, PaymentProcessCtx, PaymentProcessorContext, PaymentProcessorSessionResponse, - PaymentSessionData, PaymentSessionStatus, UpdateRequests, + PaymentSessionData, PaymentSessionStatus, PluginConfig, UpdateRequests, }; use tracing::warn; -use crate::{Intent, SetupFutureUsage, StripeCustomerMetadata}; +use crate::{Intent, SetupFutureUsage, StripeCustomerMetadata, METADATA_ADAPTER_NAME}; pub struct StripePrzelewy24 { config: StripePrzelewy24Config, client: ::stripe::Client, } +pub static PRZELEWY_24_NAME: &str = "stripe-przelewy24"; + #[async_trait::async_trait] impl PaymentAdapter for StripePrzelewy24 { - async fn new(config: Config) -> Self { - let config: StripePrzelewy24Config = - config.config().expect("Malformed Stripe Przelewy24 config"); + async fn new(config: PluginConfig) -> Self { + let config: StripePrzelewy24Config = config.config().unwrap_or_default(); let client = ::stripe::Client::new(config.api_key.as_str()); Self { config, client } } fn identifier(&self) -> &'static str { - "stripe-przelewy24" + PRZELEWY_24_NAME } async fn initialize_payment( @@ -71,6 +72,7 @@ impl PaymentAdapter for StripePrzelewy24 { metadata: Some({ let mut m = ::stripe::Metadata::with_capacity(1); m.insert("resource_id".into(), resource_id.clone()); + m.insert(METADATA_ADAPTER_NAME.into(), PRZELEWY_24_NAME.into()); m }), off_session: None, @@ -234,7 +236,7 @@ impl PaymentAdapter for StripePrzelewy24 { } async fn capture_payment( - &mut self, + &self, payment_session_data: &mut Box, ) -> PResult<()> { let Some(session) = session_mut_ref::(payment_session_data) else { @@ -319,7 +321,7 @@ impl PaymentAdapter for StripePrzelewy24 { } } -#[derive(serde::Deserialize, serde::Serialize)] +#[derive(Default, serde::Deserialize, serde::Serialize)] pub struct StripePrzelewy24Config { pub api_key: String, pub client: String, diff --git a/crates/payment-stripe-plugin/src/routes.rs b/crates/payment-stripe-plugin/src/routes.rs new file mode 100644 index 0000000..7126904 --- /dev/null +++ b/crates/payment-stripe-plugin/src/routes.rs @@ -0,0 +1,226 @@ +use actix_web::web::Data; +use actix_web::{web, HttpRequest, HttpResponse}; +use plugin_api::{find_plugin, Plugins}; +use stripe::{EventObject, EventType, Webhook, WebhookError}; +use tracing::warn; + +use crate::{Intent, StripePlugin, METADATA_ADAPTER_NAME, PLUGIN_NAME}; + +#[derive(Debug, thiserror::Error)] +pub enum HookError { + #[error("{0}")] + Webhook(#[from] WebhookError), + #[error("Invalid stripe webhook payload")] + InvalidPayload, + #[error("Stripe plugin is inactive")] + NoStripePlugin, +} + +#[actix_web::post("/stripe/hooks")] +pub async fn stripe_hooks( + req: HttpRequest, + payload: web::Bytes, + plugins: Data, +) -> HttpResponse { + if let Err(e) = handle_webhook(req, payload, plugins).await { + warn!("Failed to handle stripe hook: {e}"); + HttpResponse::Ok().finish() + } else { + HttpResponse::Ok().finish() + } +} + +async fn handle_webhook( + req: HttpRequest, + payload: web::Bytes, + plugins: Data, +) -> Result<(), HookError> { + use std::borrow::Borrow; + + let stripe = + find_plugin::(&*plugins, PLUGIN_NAME).ok_or(HookError::NoStripePlugin)?; + + let payload_str = std::str::from_utf8(payload.borrow()).map_err(|e| { + warn!("Invalid stripe payload: {e}"); + HookError::InvalidPayload + })?; + + let stripe_signature = read_header_value(&req, "Stripe-Signature") + .or_else(|| read_header_value(&req, "stripe-signature")) + .unwrap_or_default(); + + if let Ok(event) = + Webhook::construct_event(payload_str, stripe_signature, &stripe.config.webhook_secret) + { + match event.type_ { + EventType::AccountUpdated => { + if let EventObject::Account(account) = event.data.object { + handle_account_updated(account).await?; + } + } + EventType::PaymentIntentSucceeded => { + if let EventObject::PaymentIntent(intent) = event.data.object { + payment_intent_succeeded(intent, &*plugins).await?; + } + } + EventType::PaymentIntentCreated => { + if let EventObject::PaymentIntent(intent) = event.data.object { + payment_intent_created(intent, &*plugins).await?; + } + } + EventType::PaymentIntentCanceled => { + if let EventObject::PaymentIntent(intent) = event.data.object { + payment_intent_canceled(intent, &*plugins).await?; + } + } + EventType::PaymentIntentPaymentFailed => { + if let EventObject::PaymentIntent(intent) = event.data.object { + payment_intent_failed(intent, &*plugins).await?; + } + } + EventType::PaymentIntentRequiresCapture => { + if let EventObject::PaymentIntent(intent) = event.data.object { + payment_intent_requires_capture(intent, &*plugins).await?; + } + } + EventType::PaymentIntentRequiresAction => { + if let EventObject::PaymentIntent(intent) = event.data.object { + payment_intent_requires_action(intent, &*plugins).await?; + } + } + + _ => { + println!("Unknown event encountered in webhook: {:?}", event.type_); + } + } + } else { + println!("Failed to construct webhook event, ensure your webhook secret is correct."); + } + + Ok(()) +} + +fn read_header_value<'b>(req: &'b HttpRequest, key: &'b str) -> Option<&'b str> { + req.headers().get(key)?.to_str().ok() +} + +async fn handle_account_updated(account: stripe::Account) -> Result<(), HookError> { + println!( + "Received account updated webhook for account: {:?}", + account.id + ); + Ok(()) +} + +async fn payment_intent_succeeded( + intent: stripe::PaymentIntent, + plugins: &Plugins, +) -> Result<(), HookError> { + let Some(value) = intent.metadata.get(METADATA_ADAPTER_NAME) else { + return Ok(()); + }; + let Some(method) = plugins.payment(value) else { + return Ok(()); + }; + + let resource_id = intent.metadata.get("resource_id"); + let is_payment_collection = resource_id + .map(|s| s.starts_with("paycol")) + .unwrap_or_default(); + + /* + await manager.transaction(async (transactionManager) => { + if (isPaymentCollection) { + await capturePaymentCollectionIfNecessary({ + paymentIntent, + resourceId, + container, + }) + } else { + await completeCartIfNecessary({ + eventId, + cartId, + container, + transactionManager, + }) + + await capturePaymentIfNecessary({ + cartId, + transactionManager, + container, + }) + } + }) + */ + + Ok(()) +} + +async fn payment_intent_created( + intent: stripe::PaymentIntent, + plugins: &Plugins, +) -> Result<(), HookError> { + let Some(value) = intent.metadata.get(METADATA_ADAPTER_NAME) else { + return Ok(()); + }; + let Some(method) = plugins.payment(value) else { + return Ok(()); + }; + Ok(()) +} + +async fn payment_intent_canceled( + intent: stripe::PaymentIntent, + plugins: &Plugins, +) -> Result<(), HookError> { + let Some(value) = intent.metadata.get(METADATA_ADAPTER_NAME) else { + return Ok(()); + }; + let Some(method) = plugins.payment(value) else { + return Ok(()); + }; + Ok(()) +} + +async fn payment_intent_failed( + intent: stripe::PaymentIntent, + plugins: &Plugins, +) -> Result<(), HookError> { + let Some(value) = intent.metadata.get(METADATA_ADAPTER_NAME) else { + return Ok(()); + }; + let Some(method) = plugins.payment(value) else { + return Ok(()); + }; + Ok(()) +} + +async fn payment_intent_requires_capture( + intent: stripe::PaymentIntent, + plugins: &Plugins, +) -> Result<(), HookError> { + let Some(value) = intent.metadata.get(METADATA_ADAPTER_NAME) else { + return Ok(()); + }; + let Some(method) = plugins.payment(value) else { + return Ok(()); + }; + + let mut intent: Box = + Box::new(Intent::new(intent)); + method.adapter.as_ref().capture_payment(&mut intent).await; + Ok(()) +} + +async fn payment_intent_requires_action( + intent: stripe::PaymentIntent, + plugins: &Plugins, +) -> Result<(), HookError> { + let Some(value) = intent.metadata.get(METADATA_ADAPTER_NAME) else { + return Ok(()); + }; + let Some(method) = plugins.payment(value) else { + return Ok(()); + }; + Ok(()) +} diff --git a/crates/payment-stripe/src/routes.rs b/crates/payment-stripe/src/routes.rs deleted file mode 100644 index 93cdd71..0000000 --- a/crates/payment-stripe/src/routes.rs +++ /dev/null @@ -1,105 +0,0 @@ -use actix_web::web::Data; -use actix_web::{web, HttpRequest, HttpResponse}; -use payment_adapter::{find_plugin, Plugins}; -use stripe::{EventObject, EventType, Webhook, WebhookError}; -use tracing::warn; - -use crate::{StripePlugin, PLUGIN_NAME}; - -#[derive(Debug, thiserror::Error)] -pub enum HookError { - #[error("{0}")] - Webhook(#[from] WebhookError), - #[error("Invalid stripe webhook payload")] - InvalidPayload, - #[error("Stripe plugin is inactive")] - NoStripePlugin, -} - -#[actix_web::post("/stripe/hooks")] -pub async fn stripe_hooks( - req: HttpRequest, - payload: web::Bytes, - plugins: Data, -) -> HttpResponse { - if let Err(e) = handle_webhook(req, payload, plugins) { - warn!("Failed to handle stripe hook: {e}"); - HttpResponse::Ok().finish() - } else { - HttpResponse::Ok().finish() - } -} - -pub fn handle_webhook( - req: HttpRequest, - payload: web::Bytes, - plugins: Data, -) -> Result<(), HookError> { - use std::borrow::Borrow; - - let stripe = - find_plugin::(&*plugins, PLUGIN_NAME).ok_or(HookError::NoStripePlugin)?; - - let payload_str = std::str::from_utf8(payload.borrow()).map_err(|e| { - warn!("Invalid stripe payload: {e}"); - HookError::InvalidPayload - })?; - - let stripe_signature = read_header_value(&req, "Stripe-Signature") - .or_else(|| read_header_value(&req, "stripe-signature")) - .unwrap_or_default(); - - if let Ok(event) = - Webhook::construct_event(payload_str, stripe_signature, &stripe.config.webhook_secret) - { - match event.type_ { - EventType::AccountUpdated => { - if let EventObject::Account(account) = event.data.object { - handle_account_updated(account)?; - } - } - EventType::CheckoutSessionCompleted => { - if let EventObject::CheckoutSession(session) = event.data.object { - handle_checkout_session(session)?; - } - } - EventType::PaymentIntentSucceeded => { - if let EventObject::PaymentIntent(intent) = event.data.object { - handle_payment_intent(intent)?; - } - } - - _ => { - println!("Unknown event encountered in webhook: {:?}", event.type_); - } - } - } else { - println!("Failed to construct webhook event, ensure your webhook secret is correct."); - } - - Ok(()) -} - -fn read_header_value<'b>(req: &'b HttpRequest, key: &'b str) -> Option<&'b str> { - req.headers().get(key)?.to_str().ok() -} - -fn handle_account_updated(account: stripe::Account) -> Result<(), HookError> { - println!( - "Received account updated webhook for account: {:?}", - account.id - ); - Ok(()) -} - -fn handle_checkout_session(session: stripe::CheckoutSession) -> Result<(), HookError> { - println!( - "Received checkout session completed webhook with id: {:?}", - session.id - ); - Ok(()) -} - -fn handle_payment_intent(_intent: stripe::PaymentIntent) -> Result<(), HookError> { - Ok(()) -} diff --git a/crates/plugin-api/Cargo.toml b/crates/plugin-api/Cargo.toml index 32a5154..793ee99 100644 --- a/crates/plugin-api/Cargo.toml +++ b/crates/plugin-api/Cargo.toml @@ -4,8 +4,16 @@ version = "0.1.0" edition = "2021" [dependencies] +actix-web = { version = "4.3.1" } +async-trait = { version = "0.1.68" } +bincode = { version = "1.3.3" } +cache-adapter = { workspace = true } config = { path = "../config", default-features = false, features = [] } +derive_more = { version = "0.99.17" } +event-bus-adapter = { workspace = true } +file-storage-adapter = { workspace = true } +futures = { version = "0.3.28" } +payment-adapter = { workspace = true } +serde = { version = "1.0.163" } thiserror = { version = "1" } tracing = { version = "0" } -async-trait = { version = "0.1.68" } -actix-web = { version = "4.3.1" } diff --git a/crates/plugin-api/src/lib.rs b/crates/plugin-api/src/lib.rs index 0e27f09..a562b37 100644 --- a/crates/plugin-api/src/lib.rs +++ b/crates/plugin-api/src/lib.rs @@ -1,13 +1,21 @@ use std::any::Any; use std::collections::HashMap; +use std::sync::{Arc, RwLock}; use async_trait::async_trait; +use cache_adapter::{CResult, CacheAdapter, InvalidatePattern}; +pub use config::AppConfig; +use event_bus_adapter::EventBus; +use file_storage_adapter::{FileStorage, SResult, Url}; +use payment_adapter::PaymentAdapter; +use tracing::warn; #[derive(Copy, Clone, Debug)] pub enum PluginType { Payment, Cache, FileStorage, + EventBus, } #[async_trait] @@ -18,15 +26,199 @@ pub trait Plugin: Any { fn name(&self) -> &'static str; - fn mount(&self, config: &mut actix_web::web::ServiceConfig); - - async fn initialize(app_config: &config::AppConfig) + async fn initialize(app_config: &AppConfig) -> Self where Self: Sized; + + fn mount(&self, _config: &mut actix_web::web::ServiceConfig) {} + + async fn register_payment_methods(&mut self, _methods: &'static mut PaymentMethodRegister) {} + + async fn register_event_bus(&mut self, _register: &'static mut EventBusRegister) {} + + async fn register_cache(&mut self, _cache: &'static mut Cache) {} + + async fn register_file_storage(&mut self, _register: &'static mut FileStorageRegister) {} } +#[derive(Default, Clone)] +pub struct Cache { + adapter: Arc>>>, +} + +impl Cache { + pub fn register(&mut self, adapter: Box) { + *self.adapter.write().unwrap() = Some(adapter); + } + + pub async fn read(&mut self, key: &str) -> Option { + let lock = self.adapter.read().unwrap(); + let Some(adapter) = lock.as_ref() else { + return None; + }; + adapter + .read(key) + .await + .ok() + .and_then(|o| o.into_inner().ok().flatten()) + } + + pub async fn set( + &mut self, + key: &str, + o: T, + expires_in: Option, + ) { + let mut lock = self.adapter.write().unwrap(); + let Some(adapter) = lock.as_mut() else { + return; + }; + let data = match bincode::serialize(&o) { + Ok(v) => v, + Err(e) => { + warn!("Failed to serialize for cache: {e}"); + return; + } + }; + adapter.set(key, &data, expires_in).await.ok(); + } + + pub async fn invalidate(&mut self, pattern: InvalidatePattern<'_>) -> CResult { + let mut lock = self.adapter.write().unwrap(); + let Some(adapter) = lock.as_mut() else { + return Ok(0); + }; + adapter.invalidate(pattern).await + } + pub async fn clear(&mut self) -> CResult { + let mut lock = self.adapter.write().unwrap(); + let Some(adapter) = lock.as_mut() else { + return Ok(0); + }; + adapter.clear().await + } +} + +pub struct PaymentMethod { + pub adapter: Box, + enabled: bool, +} + +pub struct PaymentMethodRegister { + methods: HashMap<&'static str, PaymentMethod>, +} + +impl Default for PaymentMethodRegister { + fn default() -> Self { + Self { + methods: HashMap::with_capacity(16), + } + } +} + +impl PaymentMethodRegister { + pub fn register(&mut self, enabled: bool, method: Box) { + self.methods.insert( + method.identifier(), + PaymentMethod { + adapter: method, + enabled, + }, + ); + } +} + +#[derive(Default)] +pub struct FileStorageRegister { + name: Option<&'static str>, + adapter: Option>, + enabled: bool, +} + +impl FileStorageRegister { + pub fn register(&mut self, enabled: bool, name: &'static str, adapter: Box) { + self.enabled = enabled; + self.adapter = Some(adapter); + self.name = Some(name); + } + + pub fn name(&self) -> Option<&'static str> { + self.name + } + + pub async fn store( + &mut self, + file: Box, + ) -> Option> { + let adapter = self.adapter.as_mut()?; + Some(adapter.store(file).await) + } + pub async fn erase(&mut self, file_name: Url) -> Option> { + let adapter = self.adapter.as_mut()?; + Some(adapter.erase(file_name).await) + } +} + +pub struct EventBusRegister { + adapters: Vec, + names: Vec<&'static str>, +} + +impl EventBusRegister { + pub fn register(&mut self, name: &'static str, adapter: EventBus) { + self.names.push(name); + self.adapters.push(adapter); + } + + pub fn emit(&mut self, adapter_name: &str) { + let Some(_adapter) = self.names + .iter() + .position(|n| *n == adapter_name) + .and_then(|pos| self.adapters.get(pos)) else { + return; + }; + // adapter. + } +} + +impl Default for EventBusRegister { + fn default() -> Self { + Self { + adapters: Vec::with_capacity(16), + names: Vec::with_capacity(16), + } + } +} + +#[allow(dead_code)] pub struct Plugins { plugins: HashMap<&'static str, Box>, + payment_methods: PaymentMethodRegister, + cache: Cache, + event_bus: EventBusRegister, + file_storage: FileStorageRegister, +} + +impl Plugins { + pub fn payment(&self, name: &str) -> Option<&PaymentMethod> { + self.payment_methods.methods.get(name) + } + + pub fn cache(&self) -> Cache { + self.cache.clone() + } +} + +impl Default for Plugins { + fn default() -> Self { + Self { + plugins: Default::default(), + payment_methods: Default::default(), + cache: Default::default(), + event_bus: Default::default(), + file_storage: Default::default(), + } + } } pub fn find_plugin<'plugins, P: Plugin>( diff --git a/crates/token_manager/Cargo.toml b/crates/token_manager/Cargo.toml index 427107b..61619f6 100644 --- a/crates/token_manager/Cargo.toml +++ b/crates/token_manager/Cargo.toml @@ -17,6 +17,7 @@ derive_more = { version = "0", features = [] } dotenv = { version = "0" } futures = { version = "0" } futures-util = { version = "0", features = [] } +gumdrop = { version = "0" } hmac = { version = "0", features = [] } jwt = { version = "0", features = [] } model = { path = "../model", features = ["db"] } @@ -32,7 +33,6 @@ thiserror = { version = "1" } tokio = { version = "1", features = ['full'] } tracing = { version = "0" } uuid = { version = "1", features = ['v4'] } -gumdrop = { version = "0" } [dev-dependencies] fake = { version = "2" } diff --git a/migration/Cargo.toml b/migration/Cargo.toml new file mode 100644 index 0000000..8d43682 --- /dev/null +++ b/migration/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "migration" +version = "0.1.0" +edition = "2021" +publish = false + +[lib] +name = "migration" +path = "src/lib.rs" + +[dependencies] +async-std = { version = "1", features = ["attributes", "tokio1"] } + +[dependencies.sea-orm-migration] +version = "0.11.0" +features = [ + "sqlx-postgres" +] diff --git a/migration/README.md b/migration/README.md new file mode 100644 index 0000000..b3ea53e --- /dev/null +++ b/migration/README.md @@ -0,0 +1,41 @@ +# Running Migrator CLI + +- Generate a new migration file + ```sh + cargo run -- migrate 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/migration/src/lib.rs b/migration/src/lib.rs new file mode 100644 index 0000000..953d082 --- /dev/null +++ b/migration/src/lib.rs @@ -0,0 +1,13 @@ +pub use sea_orm_migration::prelude::*; + +mod m20230603_102634_types; +pub mod types; + +pub struct Migrator; + +#[async_trait::async_trait] +impl MigratorTrait for Migrator { + fn migrations() -> Vec> { + vec![Box::new(m20230603_102634_types::Migration)] + } +} diff --git a/migration/src/m20230603_102634_types.rs b/migration/src/m20230603_102634_types.rs new file mode 100644 index 0000000..8e84480 --- /dev/null +++ b/migration/src/m20230603_102634_types.rs @@ -0,0 +1,75 @@ +use sea_orm::{EnumIter, Iterable}; +use sea_orm_migration::prelude::*; + +use crate::extension::postgres::Type; +use crate::types::*; + +macro_rules! create_type { + ($manager: ident, $ty: ident) => { + $manager + .create_type( + Type::create() + .as_enum($ty::iter().next().unwrap()) + .values($ty::iter().skip(1)) + .to_owned(), + ) + .await?; + }; +} +macro_rules! drop_type { + ($manager: ident, $ty: ident) => { + $manager + .drop_type( + Type::drop() + .if_exists() + .cascade() + .name($ty::iter().next().unwrap()) + .to_owned(), + ) + .await?; + }; +} + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + create_type!(manager, PaymentCollectionStatus); + create_type!(manager, PaymentCollectionType); + create_type!(manager, CartType); + create_type!(manager, ClaimItemReason); + create_type!(manager, ClaimOrderFulfillmentStatus); + create_type!(manager, ClaimOrderPaymentStatus); + create_type!(manager, ClaimOrderType); + create_type!(manager, DiscountConditionOperator); + create_type!(manager, DiscountConditionType); + create_type!(manager, DiscountRuleAllocation); + create_type!(manager, DiscountRuleType); + create_type!(manager, DraftOrderStatus); + create_type!(manager, InviteRole); + create_type!(manager, OrderFulfillmentStatus); + create_type!(manager, OrderItemChangeType); + Ok(()) + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + drop_type!(manager, PaymentCollectionStatus); + drop_type!(manager, PaymentCollectionType); + drop_type!(manager, CartType); + drop_type!(manager, ClaimItemReason); + drop_type!(manager, ClaimOrderFulfillmentStatus); + drop_type!(manager, ClaimOrderPaymentStatus); + drop_type!(manager, ClaimOrderType); + drop_type!(manager, DiscountConditionOperator); + drop_type!(manager, DiscountConditionType); + drop_type!(manager, DiscountRuleAllocation); + drop_type!(manager, DiscountRuleType); + drop_type!(manager, DraftOrderStatus); + drop_type!(manager, InviteRole); + drop_type!(manager, OrderFulfillmentStatus); + drop_type!(manager, OrderItemChangeType); + Ok(()) + } +} diff --git a/migration/src/main.rs b/migration/src/main.rs new file mode 100644 index 0000000..c6b6e48 --- /dev/null +++ b/migration/src/main.rs @@ -0,0 +1,6 @@ +use sea_orm_migration::prelude::*; + +#[async_std::main] +async fn main() { + cli::run_cli(migration::Migrator).await; +} diff --git a/migration/src/types.rs b/migration/src/types.rs new file mode 100644 index 0000000..08ee6fd --- /dev/null +++ b/migration/src/types.rs @@ -0,0 +1,193 @@ +use sea_orm::{EnumIter, Iterable}; +use sea_orm_migration::prelude::*; + +#[derive(Iden, EnumIter)] +pub enum PaymentCollectionStatus { + PaymentCollectionStatuses, + #[iden = "not_paid"] + NotPaid, + #[iden = "awaiting"] + Awaiting, + #[iden = "authorized"] + Authorized, + #[iden = "partially_authorized"] + PartiallyAuthorized, + #[iden = "canceled"] + Canceled, +} + +#[derive(Iden, EnumIter)] +pub enum PaymentCollectionType { + PaymentCollectionTypes, + #[iden = "order_edit"] + OrderEdit, +} + +#[derive(Iden, EnumIter)] +pub enum CartType { + CartTypes, + #[iden = "default"] + Default, + #[iden = "swap"] + Swap, + #[iden = "draft_order"] + DraftOrder, + #[iden = "payment_link"] + PaymentLink, + #[iden = "claim"] + Claim, +} + +#[derive(Iden, EnumIter)] +pub enum ClaimItemReason { + ClaimItemReasons, + #[iden = "missing_item"] + MissingItem, + #[iden = "wrong_item"] + WrongItem, + #[iden = "production_failure"] + ProductionFailure, + #[iden = "other"] + Other, +} + +#[derive(Iden, EnumIter)] +pub enum ClaimOrderFulfillmentStatus { + ClaimOrderFulfillmentStatuses, + #[iden = "not_fulfilled"] + NotFulfilled, + #[iden = "partially_fulfilled"] + PartiallyFulfilled, + #[iden = "fulfilled"] + Fulfilled, + #[iden = "partially_shipped"] + PartiallyShipped, + #[iden = "shipped"] + Shipped, + #[iden = "partially_returned"] + PartiallyReturned, + #[iden = "returned"] + Returned, + #[iden = "canceled"] + Canceled, + #[iden = "requires_action"] + RequiresAction, +} + +#[derive(Iden, EnumIter)] +pub enum ClaimOrderPaymentStatus { + ClaimOrderPaymentStatuses, + #[iden = "na"] + NA, + #[iden = "not_refunded"] + NotRefunded, + #[iden = "refunded"] + Refunded, +} + +#[derive(Iden, EnumIter)] +pub enum ClaimOrderType { + ClaimOrderTypes, + #[iden = "refund"] + Refund, + #[iden = "replace"] + Replace, +} + +#[derive(Iden, EnumIter)] +pub enum DiscountConditionOperator { + DiscountConditionOperators, + #[iden = "in"] + In, + #[iden = "not_in"] + NotOn, +} + +#[derive(Iden, EnumIter)] +pub enum DiscountConditionType { + DiscountConditionTypes, + #[iden = "products"] + Products, + #[iden = "product_types"] + ProductTypes, + #[iden = "product_collections"] + ProductCollections, + #[iden = "product_tags"] + ProductTags, + #[iden = "customer_groups"] + CustomerGroups, +} + +#[derive(Iden, EnumIter)] +pub enum DiscountRuleAllocation { + DiscountRuleAllocations, + #[iden = "total"] + Total, + #[iden = "item"] + Item, +} + +#[derive(Iden, EnumIter)] +pub enum DiscountRuleType { + DiscountRuleTypes, + #[iden = "fixed"] + Fixed, + #[iden = "percentage"] + Percentage, + #[iden = "free_shipping"] + FreeShipping, +} + +#[derive(Iden, EnumIter)] +pub enum DraftOrderStatus { + DraftOrderStatuses, + #[iden = "open"] + Open, + #[iden = "completed"] + Completed, +} + +#[derive(Iden, EnumIter)] +pub enum InviteRole { + InviteRoles, + #[iden = "admin"] + Admin, + #[iden = "member"] + Member, + #[iden = "developer"] + Developer, +} + +#[derive(Iden, EnumIter)] +pub enum OrderFulfillmentStatus { + OrderFulfillmentStatuses, + #[iden = "not_fulfilled"] + NotFulfilled, + #[iden = "partially_fulfilled"] + PartiallyFulfilled, + #[iden = "fulfilled"] + Fulfilled, + #[iden = "partially_shipped"] + PartiallyShipped, + #[iden = "shipped"] + Shipped, + #[iden = "partially_returned"] + PartiallyReturned, + #[iden = "returned"] + Returned, + #[iden = "canceled"] + Canceled, + #[iden = "requires_action"] + RequiresAction, +} + +#[derive(Iden, EnumIter)] +pub enum OrderItemChangeType { + OrderItemChangeTypes, + #[iden = "item_add"] + ItemAdd, + #[iden = "item_remove"] + ItemRemove, + #[iden = "item_update"] + ItemUpdate, +} diff --git a/migrations/202204131841_init.sql b/migrations/202204131841_init.sql deleted file mode 100644 index abd51f0..0000000 --- a/migrations/202204131841_init.sql +++ /dev/null @@ -1,78 +0,0 @@ -CREATE EXTENSION "uuid-ossp"; - -CREATE TYPE "Role" AS ENUM ( - 'admin', - 'user' - ); - -CREATE TYPE "OrderStatus" AS ENUM ( - 'confirmed', - 'cancelled', - 'delivered', - 'payed', - 'require_refund', - 'refunded' - ); - -CREATE TYPE "QuantityUnit" AS ENUM ( - 'g', - 'dkg', - 'kg', - 'piece' - ); - -CREATE TABLE accounts -( - id serial not null primary key, - email varchar not null unique, - login varchar not null unique, - pass_hash varchar not null, - role "Role" not null default 'user' -); - -CREATE TABLE products -( - id serial not null primary key, - name varchar not null unique, - short_description varchar not null, - long_description varchar not null, - category varchar, - price_major int not null, - price_minor int not null, - CONSTRAINT positive_price_minor check ( price_major >= 0 ) -); - -CREATE TABLE stocks -( - id serial not null primary key, - product_id int references products (id) not null unique, - quantity int not null default 0, - quantity_unit "QuantityUnit" not null, - CONSTRAINT positive_quantity check ( quantity >= 0 ) -); - -CREATE TABLE account_orders -( - id serial not null primary key, - buyer_id int references accounts (id) not null, - status "OrderStatus" not null default 'confirmed' -); - -CREATE TABLE order_items -( - id serial not null primary key, - product_id int references products (id) not null, - order_id int references account_orders (id), - quantity int not null default 0, - quantity_unit "QuantityUnit" not null, - CONSTRAINT positive_quantity check ( quantity >= 0 ) -); - -CREATE TABLE "statistics" -( - id serial not null primary key, - url varchar not null, - clicks int not null default 0, - date DATE not null default now(), - CONSTRAINT positive_clicks check ( clicks >= 0 ) -); diff --git a/migrations/202204160624_create_shopping_cart.sql b/migrations/202204160624_create_shopping_cart.sql deleted file mode 100644 index 349c193..0000000 --- a/migrations/202204160624_create_shopping_cart.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TYPE "PaymentMethod" AS ENUM ( - 'pay_u', - 'payment_on_the_spot' - ); - -CREATE TABLE shopping_carts -( - id serial not null primary key, - buyer_id int references accounts (id) not null, - payment_method "PaymentMethod" NOT NULL DEFAULT 'payment_on_the_spot' -); - -CREATE TABLE shopping_cart_items -( - id serial not null primary key, - product_id int references products (id) not null, - shopping_cart_id int references shopping_carts (id), - quantity int not null default 0, - quantity_unit "QuantityUnit" not null, - CONSTRAINT positive_quantity check ( quantity >= 0 ) -); diff --git a/migrations/202204161233_add_cart_state.sql b/migrations/202204161233_add_cart_state.sql deleted file mode 100644 index ba9016a..0000000 --- a/migrations/202204161233_add_cart_state.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TYPE "ShoppingCartState" AS ENUM ( - 'active', - 'closed' -); - -ALTER TABLE shopping_carts -ADD COLUMN "state" "ShoppingCartState" NOT NULL DEFAULT 'active'; - -ALTER TABLE shopping_carts -ADD CONSTRAINT single_active_cart UNIQUE (buyer_id, "state"); diff --git a/migrations/202204172215_delivery_and_price.sql b/migrations/202204172215_delivery_and_price.sql deleted file mode 100644 index 31dc475..0000000 --- a/migrations/202204172215_delivery_and_price.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TYPE "Price" AS ( - "value" integer, - "currency" varchar -); - -ALTER TABLE products -ADD COLUMN "deliver_days_flag" int -NOT NULL --- 0x1111111 -DEFAULT 127; diff --git a/migrations/202204180708_add_payment_fields.sql b/migrations/202204180708_add_payment_fields.sql deleted file mode 100644 index 3037fdb..0000000 --- a/migrations/202204180708_add_payment_fields.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE accounts -ADD COLUMN customer_id uuid not null default gen_random_uuid(); diff --git a/migrations/202204181325_create_tokens.sql b/migrations/202204181325_create_tokens.sql deleted file mode 100644 index 3b150a7..0000000 --- a/migrations/202204181325_create_tokens.sql +++ /dev/null @@ -1,27 +0,0 @@ -CREATE TYPE "Audience" AS ENUM ( - 'web', - 'mobile', - 'feed', - 'admin_panel' -); - -CREATE TABLE tokens ( - id serial not null primary key, - customer_id uuid not null, - role "Role" not null, - -- standard fields - -- iss (issuer): Issuer of the JWT - issuer varchar not null default 'bazzar', - -- sub (subject): Subject of the JWT (the user) - subject int not null /* account_id */ , - -- aud (audience): Recipient for which the JWT is intended - audience "Audience" not null default 'web', - -- exp (expiration time): Time after which the JWT expires - expiration_time timestamp not null default now() + interval '2 weeks', - -- nbt (not before time): Time before which the JWT must not be accepted for processing - not_before_time timestamp not null default now() - interval '1 minute', - -- iat (issued at time): Time at which the JWT was issued; can be used to determine age of the JWT, - issued_at_time timestamp not null default now(), - -- jti (JWT ID): Unique identifier; can be used to prevent the JWT from being replayed (allows a token to be used only once) - jwt_id uuid not null default gen_random_uuid() -); diff --git a/migrations/202204182135_add_uniq_add_time_format.sql b/migrations/202204182135_add_uniq_add_time_format.sql deleted file mode 100644 index d7970e2..0000000 --- a/migrations/202204182135_add_uniq_add_time_format.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE tokens -ADD CONSTRAINT unit_jit UNIQUE (jwt_id); - ---SET datestyle = ''; diff --git a/migrations/202204191430_change_price.sql b/migrations/202204191430_change_price.sql deleted file mode 100644 index ff817e9..0000000 --- a/migrations/202204191430_change_price.sql +++ /dev/null @@ -1,14 +0,0 @@ -ALTER TABLE products -ADD COLUMN price integer NOT NULL; - -ALTER TABLE products -ADD CONSTRAINT non_negative CHECK (price >= 0); - -UPDATE products -SET price = price_major * 100 + price_minor; - -ALTER TABLE products -DROP COLUMN price_minor; - -ALTER TABLE products -DROP COLUMN price_major; diff --git a/migrations/202204191555_add_account_state.sql b/migrations/202204191555_add_account_state.sql deleted file mode 100644 index 2e9197c..0000000 --- a/migrations/202204191555_add_account_state.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TYPE "AccountState" AS ENUM ( - 'active', - 'suspended', - 'banned' - ); - -ALTER TABLE accounts - ADD COLUMN state "AccountState" NOT NULL DEFAULT 'active'; diff --git a/migrations/202204271359_add_order_ext_id.sql b/migrations/202204271359_add_order_ext_id.sql deleted file mode 100644 index c6130f7..0000000 --- a/migrations/202204271359_add_order_ext_id.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE account_orders -ADD COLUMN order_ext_id uuid not null default uuid_generate_v4(); diff --git a/migrations/202204300704_photos.sql b/migrations/202204300704_photos.sql deleted file mode 100644 index 473a721..0000000 --- a/migrations/202204300704_photos.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE photos ( - id serial not null primary key, - "local_path" varchar not null unique, - "hashed_path" varchar not null unique -); - -create table product_photos ( - id serial not null primary key, - product_id int references products (id) not null, - photo_id int references photos (id) not null -); diff --git a/migrations/20220504192613_add_service_order_id_to_order.sql b/migrations/20220504192613_add_service_order_id_to_order.sql deleted file mode 100644 index f212586..0000000 --- a/migrations/20220504192613_add_service_order_id_to_order.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table account_orders -ADD COLUMN service_order_id TEXT UNIQUE; diff --git a/migrations/20220506130226_rename_photos_column.sql b/migrations/20220506130226_rename_photos_column.sql deleted file mode 100644 index 69a4465..0000000 --- a/migrations/20220506130226_rename_photos_column.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE photos -RENAME COLUMN hashed_path TO file_name; diff --git a/migrations/20220509124526_add_unique_name_to_files.sql b/migrations/20220509124526_add_unique_name_to_files.sql deleted file mode 100644 index 0a91d7f..0000000 --- a/migrations/20220509124526_add_unique_name_to_files.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE photos -ADD COLUMN unique_name TEXT NOT NULL DEFAULT gen_random_uuid() :: text UNIQUE; diff --git a/migrations/20220509133117_update_photos.sql b/migrations/20220509133117_update_photos.sql deleted file mode 100644 index 6f88921..0000000 --- a/migrations/20220509133117_update_photos.sql +++ /dev/null @@ -1 +0,0 @@ -update photos set unique_name = substring(local_path, 7); diff --git a/migrations/20220519112905_add_checkout_notes.sql b/migrations/20220519112905_add_checkout_notes.sql deleted file mode 100644 index 78ba1da..0000000 --- a/migrations/20220519112905_add_checkout_notes.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE shopping_carts -ADD checkout_notes TEXT; diff --git a/migrations/20220519113031_add_checkout_notes_order.sql b/migrations/20220519113031_add_checkout_notes_order.sql deleted file mode 100644 index e8b06d0..0000000 --- a/migrations/20220519113031_add_checkout_notes_order.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE account_orders - ADD checkout_notes TEXT; diff --git a/migrations/20220519121203_account_addresses.sql b/migrations/20220519121203_account_addresses.sql deleted file mode 100644 index 1ca4b9d..0000000 --- a/migrations/20220519121203_account_addresses.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE account_addresses -( - id serial not null primary key unique, - name text not null, - email text not null, - street text not null, - city text not null, - country text not null, - zip text not null, - account_id int references accounts (id) -); diff --git a/migrations/20220523090806_change_orders.sql b/migrations/20220523090806_change_orders.sql deleted file mode 100644 index e43cb88..0000000 --- a/migrations/20220523090806_change_orders.sql +++ /dev/null @@ -1,19 +0,0 @@ -ALTER TABLE account_orders - ALTER COLUMN buyer_id DROP NOT NULL; - -CREATE TABLE order_addresses -( - id serial not null primary key unique, - name text not null, - email text not null, - street text not null, - city text not null, - country text not null, - zip text not null -); - -ALTER TABLE account_orders - ADD COLUMN address_id INT REFERENCES order_addresses (id); - -ALTER TABLE account_orders - RENAME TO orders; diff --git a/migrations/20220523095745_add_default_to_account_address.sql b/migrations/20220523095745_add_default_to_account_address.sql deleted file mode 100644 index 9c52cf3..0000000 --- a/migrations/20220523095745_add_default_to_account_address.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE account_addresses - ADD COLUMN is_default BOOLEAN NOT NULL DEFAULT false; diff --git a/migrations/20220528115140_add_phone_to_address.sql b/migrations/20220528115140_add_phone_to_address.sql deleted file mode 100644 index 24f7c74..0000000 --- a/migrations/20220528115140_add_phone_to_address.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE account_addresses - ADD COLUMN phone text NOT NULL DEFAULT ''; diff --git a/migrations/20220606123105_drop_unique_active_cart.sql b/migrations/20220606123105_drop_unique_active_cart.sql deleted file mode 100644 index defd8b6..0000000 --- a/migrations/20220606123105_drop_unique_active_cart.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE shopping_carts - DROP CONSTRAINT single_active_cart; diff --git a/migrations/20220608131251_add_phone_to_order_address.sql b/migrations/20220608131251_add_phone_to_order_address.sql deleted file mode 100644 index f5832ef..0000000 --- a/migrations/20220608131251_add_phone_to_order_address.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE order_addresses - ADD COLUMN phone TEXT NOT NULL; diff --git a/migrations/20230603073510_init.sql b/migrations/20230603073510_init.sql new file mode 100644 index 0000000..af94fc5 --- /dev/null +++ b/migrations/20230603073510_init.sql @@ -0,0 +1,5804 @@ +CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public; +COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams'; + +CREATE TYPE public.payment_collection_statuses AS ENUM ( + 'not_paid', + 'awaiting', + 'authorized', + 'partially_authorized', + 'canceled' + ); + +CREATE TYPE public.payment_collection_types AS ENUM ( + 'order_edit' + ); + +CREATE TYPE public.cart_types AS ENUM ( + 'default', + 'swap', + 'draft_order', + 'payment_link', + 'claim' + ); + +CREATE TYPE public.claim_item_reasons AS ENUM ( + 'missing_item', + 'wrong_item', + 'production_failure', + 'other' + ); + +CREATE TYPE public.claim_order_fulfillment_statuses AS ENUM ( + 'not_fulfilled', + 'partially_fulfilled', + 'fulfilled', + 'partially_shipped', + 'shipped', + 'partially_returned', + 'returned', + 'canceled', + 'requires_action' + ); + +CREATE TYPE public.claim_order_payment_statuses AS ENUM ( + 'na', + 'not_refunded', + 'refunded' + ); + +CREATE TYPE public.claim_order_types AS ENUM ( + 'refund', + 'replace' + ); + +CREATE TYPE public.discount_condition_operators AS ENUM ( + 'in', + 'not_in' + ); + +CREATE TYPE public.discount_condition_types AS ENUM ( + 'products', + 'product_types', + 'product_collections', + 'product_tags', + 'customer_groups' + ); + +CREATE TYPE public.discount_rule_allocations AS ENUM ( + 'total', + 'item' + ); + +CREATE TYPE public.discount_rule_types AS ENUM ( + 'fixed', + 'percentage', + 'free_shipping' + ); + +CREATE TYPE public.draft_order_statuses AS ENUM ( + 'open', + 'completed' + ); + +CREATE TYPE public.invite_roles AS ENUM ( + 'admin', + 'member', + 'developer' + ); + +CREATE TYPE public.order_fulfillment_statuses AS ENUM ( + 'not_fulfilled', + 'partially_fulfilled', + 'fulfilled', + 'partially_shipped', + 'shipped', + 'partially_returned', + 'returned', + 'canceled', + 'requires_action' + ); +------------------------------------------------- + +-- +-- Name: order_item_change_types; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.order_item_change_types AS ENUM ( + 'item_add', + 'item_remove', + 'item_update' + ); + + +ALTER TYPE public.order_item_change_types OWNER TO postgres; + +-- +-- Name: order_payment_statuses; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.order_payment_statuses AS ENUM ( + 'not_paid', + 'awaiting', + 'captured', + 'partially_refunded', + 'refunded', + 'canceled', + 'requires_action' + ); + + +ALTER TYPE public.order_payment_statuses OWNER TO postgres; + +-- +-- Name: order_statuses; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.order_statuses AS ENUM ( + 'pending', + 'completed', + 'archived', + 'canceled', + 'requires_action' + ); + + +ALTER TYPE public.order_statuses OWNER TO postgres; + +-- +-- Name: payment_session_statuses; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.payment_session_statuses AS ENUM ( + 'authorized', + 'pending', + 'requires_more', + 'error', + 'canceled' + ); + + +ALTER TYPE public.payment_session_statuses OWNER TO postgres; + +-- +-- Name: price_list_statuses; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.price_list_statuses AS ENUM ( + 'active', + 'draft' + ); + + +ALTER TYPE public.price_list_statuses OWNER TO postgres; + +-- +-- Name: price_list_types; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.price_list_types AS ENUM ( + 'sale', + 'override' + ); + + +ALTER TYPE public.price_list_types OWNER TO postgres; + +-- +-- Name: product_statuses; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.product_statuses AS ENUM ( + 'draft', + 'proposed', + 'published', + 'rejected' + ); + + +ALTER TYPE public.product_statuses OWNER TO postgres; + +-- +-- Name: refund_reason_enum; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.refund_reasons AS ENUM ( + 'discount', + 'return', + 'swap', + 'claim', + 'other' + ); + + +ALTER TYPE public.refund_reasons OWNER TO postgres; + +-- +-- Name: return_statuses; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.return_statuses AS ENUM ( + 'requested', + 'received', + 'requires_action', + 'canceled' + ); + + +ALTER TYPE public.return_statuses OWNER TO postgres; + +-- +-- Name: shipping_option_price_types; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.shipping_option_price_types AS ENUM ( + 'flat_rate', + 'calculated' + ); + + +ALTER TYPE public.shipping_option_price_types OWNER TO postgres; + +-- +-- Name: shipping_option_requirement_types; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.shipping_option_requirement_types AS ENUM ( + 'min_subtotal', + 'max_subtotal' + ); + + +ALTER TYPE public.shipping_option_requirement_types OWNER TO postgres; + +-- +-- Name: shipping_profile_types; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.shipping_profile_types AS ENUM ( + 'default', + 'gift_card', + 'custom' + ); + + +ALTER TYPE public.shipping_profile_types OWNER TO postgres; + +-- +-- Name: swap_fulfillment_statuses; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.swap_fulfillment_statuses AS ENUM ( + 'not_fulfilled', + 'fulfilled', + 'shipped', + 'partially_shipped', + 'canceled', + 'requires_action' + ); + + +ALTER TYPE public.swap_fulfillment_statuses OWNER TO postgres; + +-- +-- Name: swap_payment_statuses; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.swap_payment_statuses AS ENUM ( + 'not_paid', + 'awaiting', + 'captured', + 'confirmed', + 'canceled', + 'difference_refunded', + 'partially_refunded', + 'refunded', + 'requires_action' + ); + + +ALTER TYPE public.swap_payment_statuses OWNER TO postgres; + +-- +-- Name: user_roles; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.user_roles AS ENUM ( + 'admin', + 'member', + 'developer' + ); + + +ALTER TYPE public.user_roles OWNER TO postgres; + +-- +-- Name: address; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.addresses +( + id character varying NOT NULL, + customer_id character varying, + company character varying, + first_name character varying, + last_name character varying, + address_1 character varying, + address_2 character varying, + city character varying, + country_code character varying, + province character varying, + postal_code character varying, + phone character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.addresses + OWNER TO postgres; + +-- +-- Name: analytics_config; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.analytics_configs +( + id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + user_id character varying NOT NULL, + opt_out boolean DEFAULT false NOT NULL, + anonymize boolean DEFAULT false NOT NULL +); + + +ALTER TABLE public.analytics_configs + OWNER TO postgres; + +-- +-- Name: batch_job; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.batch_jobs +( + id character varying NOT NULL, + type text NOT NULL, + created_by character varying, + context jsonb, + result jsonb, + dry_run boolean DEFAULT false NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + pre_processed_at timestamp with time zone, + confirmed_at timestamp with time zone, + processing_at timestamp with time zone, + completed_at timestamp with time zone, + failed_at timestamp with time zone, + canceled_at timestamp with time zone, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone +); + + +ALTER TABLE public.batch_jobs + OWNER TO postgres; + +-- +-- Name: cart; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.carts +( + id character varying NOT NULL, + email character varying, + billing_address_id character varying, + shipping_address_id character varying, + region_id character varying NOT NULL, + customer_id character varying, + payment_id character varying, + type public.cart_types DEFAULT 'default'::public.cart_types NOT NULL, + completed_at timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + idempotency_key character varying, + context jsonb, + payment_authorized_at timestamp with time zone, + sales_channel_id character varying +); + + +ALTER TABLE public.carts + OWNER TO postgres; + +-- +-- Name: cart_discounts; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.cart_discounts +( + cart_id character varying NOT NULL, + discount_id character varying NOT NULL +); + + +ALTER TABLE public.cart_discounts + OWNER TO postgres; + +-- +-- Name: cart_gift_cards; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.cart_gift_cards +( + cart_id character varying NOT NULL, + gift_card_id character varying NOT NULL +); + + +ALTER TABLE public.cart_gift_cards + OWNER TO postgres; + +-- +-- Name: claim_image; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.claim_images +( + id character varying NOT NULL, + claim_item_id character varying NOT NULL, + url character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.claim_images + OWNER TO postgres; + +-- +-- Name: claim_item; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.claim_items +( + id character varying NOT NULL, + claim_order_id character varying NOT NULL, + item_id character varying NOT NULL, + variant_id character varying NOT NULL, + reason public.claim_item_reasons NOT NULL, + note character varying, + quantity integer NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.claim_items + OWNER TO postgres; + +-- +-- Name: claim_item_tags; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.claim_item_tags +( + item_id character varying NOT NULL, + tag_id character varying NOT NULL +); + + +ALTER TABLE public.claim_item_tags + OWNER TO postgres; + +-- +-- Name: claim_order; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.claim_orders +( + id character varying NOT NULL, + payment_status public.claim_order_payment_statuses DEFAULT 'na'::public.claim_order_payment_statuses NOT NULL, + fulfillment_status public.claim_order_fulfillment_statuses DEFAULT 'not_fulfilled'::public.claim_order_fulfillment_statuses NOT NULL, + type public.claim_order_types NOT NULL, + order_id character varying NOT NULL, + shipping_address_id character varying, + refund_amount integer, + canceled_at timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + idempotency_key character varying, + no_notification boolean +); + + +ALTER TABLE public.claim_orders + OWNER TO postgres; + +-- +-- Name: claim_tag; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.claim_tags +( + id character varying NOT NULL, + value character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.claim_tags + OWNER TO postgres; + +-- +-- Name: country; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.countries +( + id integer NOT NULL, + iso_2 character varying NOT NULL, + iso_3 character varying NOT NULL, + num_code integer NOT NULL, + name character varying NOT NULL, + display_name character varying NOT NULL, + region_id character varying +); + + +CREATE SEQUENCE public.country_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.country_id_seq + OWNER TO postgres; + +-- +-- Name: country_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.country_id_seq OWNED BY public.countries.id; + + +-- +-- Name: currency; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.currencies +( + code character varying NOT NULL, + symbol character varying NOT NULL, + symbol_native character varying NOT NULL, + name character varying NOT NULL +); + + +ALTER TABLE public.currencies + OWNER TO postgres; + +-- +-- Name: custom_shipping_option; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.custom_shipping_options +( + id character varying NOT NULL, + price integer NOT NULL, + shipping_option_id character varying NOT NULL, + cart_id character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.custom_shipping_options + OWNER TO postgres; + +-- +-- Name: customer; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.customers +( + id character varying NOT NULL, + email character varying NOT NULL, + first_name character varying, + last_name character varying, + billing_address_id character varying, + password_hash character varying, + phone character varying, + has_account boolean DEFAULT false NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.customers + OWNER TO postgres; + +-- +-- Name: customer_group; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.customer_groups +( + id character varying NOT NULL, + name character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.customer_groups + OWNER TO postgres; + +-- +-- Name: customer_group_customers; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.customer_group_customers +( + customer_group_id character varying NOT NULL, + customer_id character varying NOT NULL +); + + +ALTER TABLE public.customer_group_customers + OWNER TO postgres; + +-- +-- Name: discount; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.discounts +( + id character varying NOT NULL, + code character varying NOT NULL, + is_dynamic boolean NOT NULL, + rule_id character varying, + is_disabled boolean NOT NULL, + parent_discount_id character varying, + starts_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + ends_at timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + usage_limit integer, + usage_count integer DEFAULT 0 NOT NULL, + valid_duration character varying +); + + +ALTER TABLE public.discounts + OWNER TO postgres; + +-- +-- Name: discount_condition; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.discount_conditions +( + id character varying NOT NULL, + type public.discount_condition_types NOT NULL, + operator public.discount_condition_operators NOT NULL, + discount_rule_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.discount_conditions + OWNER TO postgres; + +-- +-- Name: discount_condition_customer_group; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.discount_condition_customer_groups +( + customer_group_id character varying NOT NULL, + condition_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb +); + + +ALTER TABLE public.discount_condition_customer_groups + OWNER TO postgres; + +-- +-- Name: discount_condition_product; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.discount_condition_products +( + product_id character varying NOT NULL, + condition_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb +); + + +ALTER TABLE public.discount_condition_products + OWNER TO postgres; + +-- +-- Name: discount_condition_product_collection; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.discount_condition_product_collections +( + product_collection_id character varying NOT NULL, + condition_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb +); + + +ALTER TABLE public.discount_condition_product_collections + OWNER TO postgres; + +-- +-- Name: discount_condition_product_tag; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.discount_condition_product_tags +( + product_tag_id character varying NOT NULL, + condition_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb +); + + +ALTER TABLE public.discount_condition_product_tags + OWNER TO postgres; + +-- +-- Name: discount_condition_product_type; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.discount_condition_product_types +( + product_type_id character varying NOT NULL, + condition_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb +); + + +ALTER TABLE public.discount_condition_product_types + OWNER TO postgres; + +-- +-- Name: discount_regions; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.discount_regions +( + discount_id character varying NOT NULL, + region_id character varying NOT NULL +); + + +ALTER TABLE public.discount_regions + OWNER TO postgres; + +-- +-- Name: discount_rule; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.discount_rules +( + id character varying NOT NULL, + description character varying, + type public.discount_rule_types NOT NULL, + value integer NOT NULL, + allocation public.discount_rule_allocations, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +-- +-- Name: discount_rule_products; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.discount_rule_products +( + discount_rule_id character varying NOT NULL, + product_id character varying NOT NULL +); + + +ALTER TABLE public.discount_rule_products + OWNER TO postgres; + +-- +-- Name: draft_order; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.draft_orders +( + id character varying NOT NULL, + status public.draft_order_statuses DEFAULT 'open'::public.draft_order_statuses NOT NULL, + display_id integer NOT NULL, + cart_id character varying, + order_id character varying, + canceled_at timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + completed_at timestamp with time zone, + metadata jsonb, + idempotency_key character varying, + no_notification_order boolean +); + + +ALTER TABLE public.draft_orders + OWNER TO postgres; + +-- +-- Name: draft_order_display_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.draft_order_display_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: draft_order_display_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.draft_order_display_id_seq OWNED BY public.draft_orders.display_id; + + +-- +-- Name: fulfillment; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.fulfillments +( + id character varying NOT NULL, + swap_id character varying, + order_id character varying, + tracking_numbers jsonb DEFAULT '[]'::jsonb NOT NULL, + data jsonb NOT NULL, + shipped_at timestamp with time zone, + canceled_at timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb, + idempotency_key character varying, + provider_id character varying, + claim_order_id character varying, + no_notification boolean, + location_id character varying +); + + +ALTER TABLE public.fulfillments + OWNER TO postgres; + +-- +-- Name: fulfillment_item; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.fulfillment_items +( + fulfillment_id character varying NOT NULL, + item_id character varying NOT NULL, + quantity integer NOT NULL +); + + +ALTER TABLE public.fulfillment_items + OWNER TO postgres; + +-- +-- Name: fulfillment_provider; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.fulfillment_providers +( + id character varying NOT NULL, + is_installed boolean DEFAULT true NOT NULL +); + + +ALTER TABLE public.fulfillment_providers + OWNER TO postgres; + +-- +-- Name: gift_card; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.gift_cards +( + id character varying NOT NULL, + code character varying NOT NULL, + value integer NOT NULL, + balance integer NOT NULL, + region_id character varying NOT NULL, + order_id character varying, + is_disabled boolean DEFAULT false NOT NULL, + ends_at timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + tax_rate real +); + + +ALTER TABLE public.gift_cards + OWNER TO postgres; + +-- +-- Name: gift_card_transaction; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.gift_card_transactions +( + id character varying NOT NULL, + gift_card_id character varying NOT NULL, + order_id character varying NOT NULL, + amount integer NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + is_taxable boolean, + tax_rate real +); + + +ALTER TABLE public.gift_card_transactions + OWNER TO postgres; + +-- +-- Name: idempotency_key; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.idempotency_keys +( + id character varying NOT NULL, + idempotency_key character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + locked_at timestamp with time zone, + request_method character varying, + request_params jsonb, + request_path character varying, + response_code integer, + response_body jsonb, + recovery_point character varying DEFAULT 'started'::character varying NOT NULL +); + + +ALTER TABLE public.idempotency_keys + OWNER TO postgres; + +-- +-- Name: image; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.images +( + id character varying NOT NULL, + url character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.images + OWNER TO postgres; + +-- +-- Name: invite; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.invites +( + id character varying NOT NULL, + user_email character varying NOT NULL, + role public.invite_roles DEFAULT 'member'::public.invite_roles, + accepted boolean DEFAULT false NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + token character varying NOT NULL, + expires_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE public.invites + OWNER TO postgres; + +-- +-- Name: line_item; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.line_items +( + id character varying NOT NULL, + cart_id character varying, + order_id character varying, + swap_id character varying, + title character varying NOT NULL, + description character varying, + thumbnail character varying, + is_giftcard boolean DEFAULT false NOT NULL, + should_merge boolean DEFAULT true NOT NULL, + allow_discounts boolean DEFAULT true NOT NULL, + has_shipping boolean, + unit_price integer NOT NULL, + variant_id character varying, + quantity integer NOT NULL, + fulfilled_quantity integer, + returned_quantity integer, + shipped_quantity integer, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb, + claim_order_id character varying, + is_return boolean DEFAULT false NOT NULL, + original_item_id character varying, + order_edit_id character varying, + CONSTRAINT "CHK_0cd85e15610d11b553d5e8fda6" CHECK ((shipped_quantity <= fulfilled_quantity)), + CONSTRAINT "CHK_64eef00a5064887634f1680866" CHECK ((quantity > 0)), + CONSTRAINT "CHK_91f40396d847f6ecfd9f752bf8" CHECK ((returned_quantity <= quantity)), + CONSTRAINT "CHK_c61716c68f5ad5de2834c827d3" CHECK ((fulfilled_quantity <= quantity)) +); + + +ALTER TABLE public.line_items + OWNER TO postgres; + +-- +-- Name: line_item_adjustment; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.line_item_adjustments +( + id character varying NOT NULL, + item_id character varying NOT NULL, + description character varying NOT NULL, + discount_id character varying, + amount numeric NOT NULL, + metadata jsonb +); + + +ALTER TABLE public.line_item_adjustments + OWNER TO postgres; + +-- +-- Name: line_item_tax_line; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.line_item_tax_lines +( + id character varying NOT NULL, + rate real NOT NULL, + name character varying NOT NULL, + code character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb, + item_id character varying NOT NULL +); + + +ALTER TABLE public.line_item_tax_lines + OWNER TO postgres; + +-- +-- Name: migrations; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.migrations +( + id integer NOT NULL, + "timestamp" bigint NOT NULL, + name character varying NOT NULL +); + + +ALTER TABLE public.migrations + OWNER TO postgres; + +-- +-- Name: migrations_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.migrations_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.migrations_id_seq + OWNER TO postgres; + +-- +-- Name: migrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.migrations_id_seq OWNED BY public.migrations.id; + + +-- +-- Name: money_amount; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.money_amounts +( + id character varying NOT NULL, + currency_code character varying NOT NULL, + amount integer NOT NULL, + variant_id character varying, + region_id character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + min_quantity integer, + max_quantity integer, + price_list_id character varying +); + + +ALTER TABLE public.money_amounts + OWNER TO postgres; + +-- +-- Name: note; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.notes +( + id character varying NOT NULL, + value character varying NOT NULL, + resource_type character varying NOT NULL, + resource_id character varying NOT NULL, + author_id character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.notes + OWNER TO postgres; + +-- +-- Name: notification; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.notifications +( + id character varying NOT NULL, + event_name character varying, + resource_type character varying NOT NULL, + resource_id character varying NOT NULL, + customer_id character varying, + "to" character varying NOT NULL, + data jsonb NOT NULL, + parent_id character varying, + provider_id character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE public.notifications + OWNER TO postgres; + +-- +-- Name: notification_provider; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.notification_providers +( + id character varying NOT NULL, + is_installed boolean DEFAULT true NOT NULL +); + + +ALTER TABLE public.notification_providers + OWNER TO postgres; + +-- +-- Name: oauth; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.oauth +( + id character varying NOT NULL, + display_name character varying NOT NULL, + application_name character varying NOT NULL, + install_url character varying, + uninstall_url character varying, + data jsonb +); + + +ALTER TABLE public.oauth + OWNER TO postgres; + +-- +-- Name: order; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.orders +( + id character varying NOT NULL, + status public.order_statuses DEFAULT 'pending'::public.order_statuses NOT NULL, + fulfillment_status public.order_fulfillment_statuses DEFAULT 'not_fulfilled'::public.order_fulfillment_statuses NOT NULL, + payment_status public.order_payment_statuses DEFAULT 'not_paid'::public.order_payment_statuses NOT NULL, + display_id integer NOT NULL, + cart_id character varying, + customer_id character varying NOT NULL, + email character varying NOT NULL, + billing_address_id character varying, + shipping_address_id character varying, + region_id character varying NOT NULL, + currency_code character varying NOT NULL, + tax_rate real, + canceled_at timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb, + idempotency_key character varying, + draft_order_id character varying, + no_notification boolean, + external_id character varying, + sales_channel_id character varying +); + + +ALTER TABLE public.orders + OWNER TO postgres; + +-- +-- Name: order_discounts; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.order_discounts +( + order_id character varying NOT NULL, + discount_id character varying NOT NULL +); + + +ALTER TABLE public.order_discounts + OWNER TO postgres; + +-- +-- Name: order_display_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.order_display_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.order_display_id_seq + OWNER TO postgres; + +-- +-- Name: order_display_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.order_display_id_seq OWNED BY public.orders.display_id; + + +-- +-- Name: order_edit; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.order_edits +( + id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + order_id character varying NOT NULL, + internal_note character varying, + created_by character varying NOT NULL, + requested_by character varying, + requested_at timestamp with time zone, + confirmed_by character varying, + confirmed_at timestamp with time zone, + declined_by character varying, + declined_reason character varying, + declined_at timestamp with time zone, + canceled_by character varying, + canceled_at timestamp with time zone, + payment_collection_id character varying +); + + +ALTER TABLE public.order_edits + OWNER TO postgres; + +-- +-- Name: order_gift_cards; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.order_gift_cards +( + order_id character varying NOT NULL, + gift_card_id character varying NOT NULL +); + + +ALTER TABLE public.order_gift_cards + OWNER TO postgres; + +-- +-- Name: order_item_change; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.order_item_changes +( + id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + type public.order_item_change_types NOT NULL, + order_edit_id character varying NOT NULL, + original_line_item_id character varying, + line_item_id character varying +); + + +ALTER TABLE public.order_item_changes + OWNER TO postgres; + +-- +-- Name: payment; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.payments +( + id character varying NOT NULL, + swap_id character varying, + cart_id character varying, + order_id character varying, + amount integer NOT NULL, + currency_code character varying NOT NULL, + amount_refunded integer DEFAULT 0 NOT NULL, + provider_id character varying NOT NULL, + data jsonb NOT NULL, + captured_at timestamp with time zone, + canceled_at timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb, + idempotency_key character varying +); + + +ALTER TABLE public.payments + OWNER TO postgres; + +-- +-- Name: payment_collection; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.payment_collections +( + id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + type public.payment_collection_types NOT NULL, + status public.payment_collection_statuses NOT NULL, + description text, + amount integer NOT NULL, + authorized_amount integer, + region_id character varying NOT NULL, + currency_code character varying NOT NULL, + metadata jsonb, + created_by character varying NOT NULL +); + + +ALTER TABLE public.payment_collections + OWNER TO postgres; + +-- +-- Name: payment_collection_payments; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.payment_collection_payments +( + payment_collection_id character varying NOT NULL, + payment_id character varying NOT NULL +); + + +ALTER TABLE public.payment_collection_payments + OWNER TO postgres; + +-- +-- Name: payment_collection_sessions; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.payment_collection_sessions +( + payment_collection_id character varying NOT NULL, + payment_session_id character varying NOT NULL +); + + +ALTER TABLE public.payment_collection_sessions + OWNER TO postgres; + +-- +-- Name: payment_provider; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.payment_providers +( + id character varying NOT NULL, + is_installed boolean DEFAULT true NOT NULL +); + + +ALTER TABLE public.payment_providers + OWNER TO postgres; + +-- +-- Name: payment_session; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.payment_sessions +( + id character varying NOT NULL, + cart_id character varying, + provider_id character varying NOT NULL, + is_selected boolean, + status public.payment_session_statuses NOT NULL, + data jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + idempotency_key character varying, + payment_authorized_at timestamp with time zone, + amount integer, + is_initiated boolean DEFAULT false NOT NULL +); + + +ALTER TABLE public.payment_sessions + OWNER TO postgres; + +-- +-- Name: price_list; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.price_lists +( + id character varying NOT NULL, + name character varying NOT NULL, + description character varying NOT NULL, + type public.price_list_types DEFAULT 'sale'::public.price_list_types NOT NULL, + status public.price_list_statuses DEFAULT 'draft'::public.price_list_statuses NOT NULL, + starts_at timestamp with time zone, + ends_at timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone +); + + +ALTER TABLE public.price_lists + OWNER TO postgres; + +-- +-- Name: price_list_customer_groups; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.price_list_customer_groups +( + price_list_id character varying NOT NULL, + customer_group_id character varying NOT NULL +); + + +ALTER TABLE public.price_list_customer_groups + OWNER TO postgres; + +-- +-- Name: product; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.products +( + id character varying NOT NULL, + title character varying NOT NULL, + subtitle character varying, + description character varying, + handle character varying, + is_giftcard boolean DEFAULT false NOT NULL, + thumbnail character varying, + profile_id character varying NOT NULL, + weight integer, + length integer, + height integer, + width integer, + hs_code character varying, + origin_country character varying, + mid_code character varying, + material character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + collection_id character varying, + type_id character varying, + discountable boolean DEFAULT true NOT NULL, + status public.product_statuses DEFAULT 'draft'::public.product_statuses NOT NULL, + external_id character varying +); + + +ALTER TABLE public.products + OWNER TO postgres; + +-- +-- Name: product_category; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_categories +( + id character varying NOT NULL, + name text NOT NULL, + handle text NOT NULL, + parent_category_id character varying, + mpath text, + is_active boolean DEFAULT false, + is_internal boolean DEFAULT false, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + rank integer DEFAULT 0 NOT NULL, + description text DEFAULT ''::text NOT NULL, + CONSTRAINT product_category_rank_check CHECK ((rank >= 0)) +); + + +ALTER TABLE public.product_categories + OWNER TO postgres; + +-- +-- Name: product_category_product; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_category_products +( + product_category_id character varying NOT NULL, + product_id character varying NOT NULL +); + + +ALTER TABLE public.product_category_products + OWNER TO postgres; + +-- +-- Name: product_collection; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_collections +( + id character varying NOT NULL, + title character varying NOT NULL, + handle character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.product_collections + OWNER TO postgres; + +-- +-- Name: product_images; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_images +( + product_id character varying NOT NULL, + image_id character varying NOT NULL +); + + +ALTER TABLE public.product_images + OWNER TO postgres; + +-- +-- Name: product_option; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_options +( + id character varying NOT NULL, + title character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + product_id character varying +); + + +ALTER TABLE public.product_options + OWNER TO postgres; + +-- +-- Name: product_option_value; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_option_values +( + id character varying NOT NULL, + value character varying NOT NULL, + option_id character varying NOT NULL, + variant_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.product_option_values + OWNER TO postgres; + +-- +-- Name: product_sales_channel; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_sales_channels +( + product_id character varying NOT NULL, + sales_channel_id character varying NOT NULL +); + + +ALTER TABLE public.product_sales_channels + OWNER TO postgres; + +-- +-- Name: product_tag; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_tags +( + id character varying NOT NULL, + value character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.product_tags + OWNER TO postgres; + +-- +-- Name: product_tags; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_to_tags +( + product_id character varying NOT NULL, + product_tag_id character varying NOT NULL +); + + +ALTER TABLE public.product_to_tags + OWNER TO postgres; + +-- +-- Name: product_tax_rate; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_tax_rates +( + product_id character varying NOT NULL, + rate_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb +); + + +ALTER TABLE public.product_tax_rates + OWNER TO postgres; + +-- +-- Name: product_type; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_types +( + id character varying NOT NULL, + value character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.product_types + OWNER TO postgres; + +-- +-- Name: product_type_tax_rate; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_type_tax_rates +( + product_type_id character varying NOT NULL, + rate_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb +); + + +ALTER TABLE public.product_type_tax_rates + OWNER TO postgres; + +-- +-- Name: product_variant; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_variants +( + id character varying NOT NULL, + title character varying NOT NULL, + product_id character varying NOT NULL, + sku character varying, + barcode character varying, + ean character varying, + upc character varying, + inventory_quantity integer NOT NULL, + allow_backorder boolean DEFAULT false NOT NULL, + manage_inventory boolean DEFAULT true NOT NULL, + hs_code character varying, + origin_country character varying, + mid_code character varying, + material character varying, + weight integer, + length integer, + height integer, + width integer, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + variant_rank integer DEFAULT 0 +); + + +ALTER TABLE public.product_variants + OWNER TO postgres; + +-- +-- Name: product_variant_inventory_item; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.product_variant_inventory_items +( + id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + inventory_item_id text NOT NULL, + variant_id text NOT NULL, + required_quantity integer DEFAULT 1 NOT NULL, + deleted_at timestamp with time zone +); + + +ALTER TABLE public.product_variant_inventory_items + OWNER TO postgres; + +-- +-- Name: publishable_api_key; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.publishable_api_keys +( + id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + created_by character varying, + revoked_by character varying, + revoked_at timestamp with time zone, + title character varying NOT NULL +); + + +ALTER TABLE public.publishable_api_keys + OWNER TO postgres; + +-- +-- Name: publishable_api_key_sales_channel; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.publishable_api_key_sales_channels +( + sales_channel_id character varying NOT NULL, + publishable_key_id character varying NOT NULL +); + + +ALTER TABLE public.publishable_api_key_sales_channels + OWNER TO postgres; + +-- +-- Name: refund; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.refunds +( + id character varying NOT NULL, + order_id character varying, + amount integer NOT NULL, + note character varying, + reason public.refund_reasons NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb, + idempotency_key character varying, + payment_id character varying +); + + +ALTER TABLE public.refunds + OWNER TO postgres; + +-- +-- Name: region; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.regions +( + id character varying NOT NULL, + name character varying NOT NULL, + currency_code character varying NOT NULL, + tax_rate real NOT NULL, + tax_code character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + gift_cards_taxable boolean DEFAULT true NOT NULL, + automatic_taxes boolean DEFAULT true NOT NULL, + tax_provider_id character varying +); + + +ALTER TABLE public.regions + OWNER TO postgres; + +-- +-- Name: region_fulfillment_providers; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.region_fulfillment_providers +( + region_id character varying NOT NULL, + provider_id character varying NOT NULL +); + + +ALTER TABLE public.region_fulfillment_providers + OWNER TO postgres; + +-- +-- Name: region_payment_providers; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.region_payment_providers +( + region_id character varying NOT NULL, + provider_id character varying NOT NULL +); + + +ALTER TABLE public.region_payment_providers + OWNER TO postgres; + +-- +-- Name: return; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.returns +( + id character varying NOT NULL, + status public.return_statuses DEFAULT 'requested'::public.return_statuses NOT NULL, + swap_id character varying, + order_id character varying, + shipping_data jsonb, + refund_amount integer NOT NULL, + received_at timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb, + idempotency_key character varying, + claim_order_id character varying, + no_notification boolean, + location_id character varying +); + + +ALTER TABLE public.returns + OWNER TO postgres; + +-- +-- Name: return_item; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.return_items +( + return_id character varying NOT NULL, + item_id character varying NOT NULL, + quantity integer NOT NULL, + is_requested boolean DEFAULT true NOT NULL, + requested_quantity integer, + received_quantity integer, + metadata jsonb, + reason_id character varying, + note character varying +); + + +ALTER TABLE public.return_items + OWNER TO postgres; + +-- +-- Name: return_reason; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.return_reasons +( + id character varying NOT NULL, + value character varying NOT NULL, + label character varying NOT NULL, + description character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + parent_return_reason_id character varying +); + + +ALTER TABLE public.return_reasons + OWNER TO postgres; + +-- +-- Name: sales_channel; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.sales_channels +( + id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + name character varying NOT NULL, + description character varying, + is_disabled boolean DEFAULT false NOT NULL, + metadata jsonb +); + + +ALTER TABLE public.sales_channels + OWNER TO postgres; + +-- +-- Name: sales_channel_location; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.sales_channel_locations +( + id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + sales_channel_id text NOT NULL, + location_id text NOT NULL, + deleted_at timestamp with time zone +); + + +ALTER TABLE public.sales_channel_locations + OWNER TO postgres; + +-- +-- Name: shipping_method; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.shipping_methods +( + id character varying NOT NULL, + shipping_option_id character varying NOT NULL, + order_id character varying, + cart_id character varying, + swap_id character varying, + return_id character varying, + price integer NOT NULL, + data jsonb NOT NULL, + claim_order_id character varying, + CONSTRAINT "CHK_64c6812fe7815be30d688df513" CHECK ((price >= 0)), + CONSTRAINT "CHK_a7020b08665bbd64d84a6641cf" CHECK (((claim_order_id IS NOT NULL) OR (order_id IS NOT NULL) OR + (cart_id IS NOT NULL) OR (swap_id IS NOT NULL) OR + (return_id IS NOT NULL))) +); + + +ALTER TABLE public.shipping_methods + OWNER TO postgres; + +-- +-- Name: shipping_method_tax_line; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.shipping_method_tax_lines +( + id character varying NOT NULL, + rate real NOT NULL, + name character varying NOT NULL, + code character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb, + shipping_method_id character varying NOT NULL +); + + +ALTER TABLE public.shipping_method_tax_lines + OWNER TO postgres; + +-- +-- Name: shipping_option; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.shipping_options +( + id character varying NOT NULL, + name character varying NOT NULL, + region_id character varying NOT NULL, + profile_id character varying NOT NULL, + provider_id character varying NOT NULL, + price_type public.shipping_option_price_types NOT NULL, + amount integer, + is_return boolean DEFAULT false NOT NULL, + data jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + admin_only boolean DEFAULT false NOT NULL, + CONSTRAINT "CHK_7a367f5901ae0a5b0df75aee38" CHECK ((amount >= 0)) +); + + +ALTER TABLE public.shipping_options + OWNER TO postgres; + +-- +-- Name: shipping_option_requirement; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.shipping_option_requirements +( + id character varying NOT NULL, + shipping_option_id character varying NOT NULL, + type public.shipping_option_requirement_types NOT NULL, + amount integer NOT NULL, + deleted_at timestamp with time zone +); + + +ALTER TABLE public.shipping_option_requirements + OWNER TO postgres; + +-- +-- Name: shipping_profile; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.shipping_profiles +( + id character varying NOT NULL, + name character varying NOT NULL, + type public.shipping_profile_types NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb +); + + +ALTER TABLE public.shipping_profiles + OWNER TO postgres; + +-- +-- Name: shipping_tax_rate; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.shipping_tax_rates +( + shipping_option_id character varying NOT NULL, + rate_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb +); + + +ALTER TABLE public.shipping_tax_rates + OWNER TO postgres; + +-- +-- Name: staged_job; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.staged_jobs +( + id character varying NOT NULL, + event_name character varying NOT NULL, + data jsonb NOT NULL, + options jsonb DEFAULT '{}'::jsonb NOT NULL +); + + +ALTER TABLE public.staged_jobs + OWNER TO postgres; + +-- +-- Name: store; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.stores +( + id character varying NOT NULL, + name character varying DEFAULT 'Bazaar'::character varying NOT NULL, + default_currency_code character varying DEFAULT 'pln'::character varying NOT NULL, + swap_link_template character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb, + payment_link_template character varying, + invite_link_template character varying, + default_sales_channel_id character varying, + default_location_id character varying +); + + +ALTER TABLE public.stores + OWNER TO postgres; + +-- +-- Name: store_currencies; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.store_currencies +( + store_id character varying NOT NULL, + currency_code character varying NOT NULL +); + + +ALTER TABLE public.store_currencies + OWNER TO postgres; + +-- +-- Name: swap; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.swaps +( + id character varying NOT NULL, + fulfillment_status public.swap_fulfillment_statuses NOT NULL, + payment_status public.swap_payment_statuses NOT NULL, + order_id character varying NOT NULL, + difference_due integer, + shipping_address_id character varying, + cart_id character varying, + confirmed_at timestamp with time zone, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + idempotency_key character varying, + no_notification boolean, + canceled_at timestamp with time zone, + allow_backorder boolean DEFAULT false NOT NULL +); + + +ALTER TABLE public.swaps + OWNER TO postgres; + +-- +-- Name: tax_provider; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.tax_providers +( + id character varying NOT NULL, + is_installed boolean DEFAULT true NOT NULL +); + + +ALTER TABLE public.tax_providers + OWNER TO postgres; + +-- +-- Name: tax_rate; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.tax_rates +( + id character varying NOT NULL, + rate real, + code character varying, + name character varying NOT NULL, + region_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + metadata jsonb +); + + +ALTER TABLE public.tax_rates + OWNER TO postgres; + +-- +-- Name: tracking_link; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.tracking_links +( + id character varying NOT NULL, + url character varying, + tracking_number character varying NOT NULL, + fulfillment_id character varying NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + idempotency_key character varying +); + + +ALTER TABLE public.tracking_links + OWNER TO postgres; + +-- +-- Name: user; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.users +( + id character varying NOT NULL, + email character varying NOT NULL, + first_name character varying, + last_name character varying, + password_hash character varying, + api_token character varying, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + metadata jsonb, + role public.user_roles DEFAULT 'member'::public.user_roles +); + + +ALTER TABLE ONLY public.countries + ALTER COLUMN id SET DEFAULT nextval('public.country_id_seq'::regclass); + + +-- +-- Name: draft_order display_id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.draft_orders + ALTER COLUMN display_id SET DEFAULT nextval('public.draft_order_display_id_seq'::regclass); + + +-- +-- Name: migrations id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.migrations + ALTER COLUMN id SET DEFAULT nextval('public.migrations_id_seq'::regclass); + + +-- +-- Name: order display_id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ALTER COLUMN display_id SET DEFAULT nextval('public.order_display_id_seq'::regclass); + + +-- +-- Name: payment_session OneSelected; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_sessions + ADD CONSTRAINT "OneSelected" UNIQUE (cart_id, is_selected); + + +-- +-- Name: money_amount PK_022e49a7e21a8dfb820f788778a; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.money_amounts + ADD CONSTRAINT "PK_022e49a7e21a8dfb820f788778a" PRIMARY KEY (id); + + +-- +-- Name: notification_provider PK_0425c2423e2ce9fdfd5c23761d9; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.notification_providers + ADD CONSTRAINT "PK_0425c2423e2ce9fdfd5c23761d9" PRIMARY KEY (id); + + +-- +-- Name: store_currencies PK_0f2bff3bccc785c320a4df836de; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.store_currencies + ADD CONSTRAINT "PK_0f2bff3bccc785c320a4df836de" PRIMARY KEY (store_id, currency_code); + + +-- +-- Name: order PK_1031171c13130102495201e3e20; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ADD CONSTRAINT "PK_1031171c13130102495201e3e20" PRIMARY KEY (id); + + +-- +-- Name: cart_discounts PK_10bd412c9071ccc0cf555afd9bb; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.cart_discounts + ADD CONSTRAINT "PK_10bd412c9071ccc0cf555afd9bb" PRIMARY KEY (cart_id, discount_id); + + +-- +-- Name: product_images PK_10de97980da2e939c4c0e8423f2; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_images + ADD CONSTRAINT "PK_10de97980da2e939c4c0e8423f2" PRIMARY KEY (product_id, image_id); + + +-- +-- Name: product_tag PK_1439455c6528caa94fcc8564fda; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_tags + ADD CONSTRAINT "PK_1439455c6528caa94fcc8564fda" PRIMARY KEY (id); + + +-- +-- Name: discount_regions PK_15974566a8b6e04a7c754e85b75; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_regions + ADD CONSTRAINT "PK_15974566a8b6e04a7c754e85b75" PRIMARY KEY (discount_id, region_id); + + +-- +-- Name: product_variant PK_1ab69c9935c61f7c70791ae0a9f; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_variants + ADD CONSTRAINT "PK_1ab69c9935c61f7c70791ae0a9f" PRIMARY KEY (id); + + +-- +-- Name: price_list_customer_groups PK_1afcbe15cc8782dc80c05707df9; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.price_list_customer_groups + ADD CONSTRAINT "PK_1afcbe15cc8782dc80c05707df9" PRIMARY KEY (price_list_id, customer_group_id); + + +-- +-- Name: product_tags PK_1cf5c9537e7198df494b71b993f; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_to_tags + ADD CONSTRAINT "PK_1cf5c9537e7198df494b71b993f" PRIMARY KEY (product_id, product_tag_id); + + +-- +-- Name: idempotency_key PK_213f125e14469be304f9ff1d452; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.idempotency_keys + ADD CONSTRAINT "PK_213f125e14469be304f9ff1d452" PRIMARY KEY (id); + + +-- +-- Name: cart_gift_cards PK_2389be82bf0ef3635e2014c9ef1; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.cart_gift_cards + ADD CONSTRAINT "PK_2389be82bf0ef3635e2014c9ef1" PRIMARY KEY (cart_id, gift_card_id); + + +-- +-- Name: tax_rate PK_23b71b53f650c0b39e99ccef4fd; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.tax_rates + ADD CONSTRAINT "PK_23b71b53f650c0b39e99ccef4fd" PRIMARY KEY (id); + + +-- +-- Name: product_option_value PK_2ab71ed3b21be5800905c621535; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_option_values + ADD CONSTRAINT "PK_2ab71ed3b21be5800905c621535" PRIMARY KEY (id); + + +-- +-- Name: line_item_adjustment PK_2b1360103753df2dc8257c2c8c3; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_item_adjustments + ADD CONSTRAINT "PK_2b1360103753df2dc8257c2c8c3" PRIMARY KEY (id); + + +-- +-- Name: shipping_option PK_2e56fddaa65f3a26d402e5d786e; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_options + ADD CONSTRAINT "PK_2e56fddaa65f3a26d402e5d786e" PRIMARY KEY (id); + + +-- +-- Name: product_tax_rate PK_326257ce468df46cd5c8c5922e9; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_tax_rates + ADD CONSTRAINT "PK_326257ce468df46cd5c8c5922e9" PRIMARY KEY (product_id, rate_id); + + +-- +-- Name: discount_rule_products PK_351c8c92f5d27283c445cd022ee; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_rule_products + ADD CONSTRAINT "PK_351c8c92f5d27283c445cd022ee" PRIMARY KEY (discount_rule_id, product_id); + + +-- +-- Name: discount_condition_product_type PK_35d538a5a24399d0df978df12ed; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_product_types + ADD CONSTRAINT "PK_35d538a5a24399d0df978df12ed" PRIMARY KEY (product_type_id, condition_id); + + +-- +-- Name: return_item PK_46409dc1dd5f38509b9000c3069; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.return_items + ADD CONSTRAINT "PK_46409dc1dd5f38509b9000c3069" PRIMARY KEY (return_id, item_id); + + +-- +-- Name: order_gift_cards PK_49a8ec66a6625d7c2e3526e05b4; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_gift_cards + ADD CONSTRAINT "PK_49a8ec66a6625d7c2e3526e05b4" PRIMARY KEY (order_id, gift_card_id); + + +-- +-- Name: product_collection PK_49d419fc77d3aed46c835c558ac; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_collections + ADD CONSTRAINT "PK_49d419fc77d3aed46c835c558ac" PRIMARY KEY (id); + + +-- +-- Name: line_item_tax_line PK_4a0f4322fcd5ce4af85727f89a8; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_item_tax_lines + ADD CONSTRAINT "PK_4a0f4322fcd5ce4af85727f89a8" PRIMARY KEY (id); + + +-- +-- Name: swap PK_4a10d0f359339acef77e7f986d9; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.swaps + ADD CONSTRAINT "PK_4a10d0f359339acef77e7f986d9" PRIMARY KEY (id); + + +-- +-- Name: product_option PK_4cf3c467e9bc764bdd32c4cd938; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_options + ADD CONSTRAINT "PK_4cf3c467e9bc764bdd32c4cd938" PRIMARY KEY (id); + + +-- +-- Name: fulfillment PK_50c102da132afffae660585981f; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.fulfillments + ADD CONSTRAINT "PK_50c102da132afffae660585981f" PRIMARY KEY (id); + + +-- +-- Name: price_list PK_52ea7826468b1c889cb2c28df03; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.price_lists + ADD CONSTRAINT "PK_52ea7826468b1c889cb2c28df03" PRIMARY KEY (id); + + +-- +-- Name: claim_item_tags PK_54ab8ce0f7e99167068188fbd81; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_item_tags + ADD CONSTRAINT "PK_54ab8ce0f7e99167068188fbd81" PRIMARY KEY (item_id, tag_id); + + +-- +-- Name: shipping_method_tax_line PK_54c94f5908aacbd51cf0a73edb1; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_method_tax_lines + ADD CONSTRAINT "PK_54c94f5908aacbd51cf0a73edb1" PRIMARY KEY (id); + + +-- +-- Name: claim_item PK_5679662039bc4c7c6bc7fa1be2d; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_items + ADD CONSTRAINT "PK_5679662039bc4c7c6bc7fa1be2d" PRIMARY KEY (id); + + +-- +-- Name: order_edit PK_58ab6acf2e84b4e827f5f846f7a; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_edits + ADD CONSTRAINT "PK_58ab6acf2e84b4e827f5f846f7a" PRIMARY KEY (id); + + +-- +-- Name: region_fulfillment_providers PK_5b7d928a1fb50d6803868cfab3a; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.region_fulfillment_providers + ADD CONSTRAINT "PK_5b7d928a1fb50d6803868cfab3a" PRIMARY KEY (region_id, provider_id); + + +-- +-- Name: region PK_5f48ffc3af96bc486f5f3f3a6da; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.regions + ADD CONSTRAINT "PK_5f48ffc3af96bc486f5f3f3a6da" PRIMARY KEY (id); + + +-- +-- Name: publishable_api_key_sales_channel PK_68eaeb14bdac8954460054c567c; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.publishable_api_key_sales_channels + ADD CONSTRAINT "PK_68eaeb14bdac8954460054c567c" PRIMARY KEY (sales_channel_id, publishable_key_id); + + +-- +-- Name: notification PK_705b6c7cdf9b2c2ff7ac7872cb7; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.notifications + ADD CONSTRAINT "PK_705b6c7cdf9b2c2ff7ac7872cb7" PRIMARY KEY (id); + + +-- +-- Name: currency PK_723472e41cae44beb0763f4039c; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.currencies + ADD CONSTRAINT "PK_723472e41cae44beb0763f4039c" PRIMARY KEY (code); + + +-- +-- Name: claim_tag PK_7761180541142a5926501018d34; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_tags + ADD CONSTRAINT "PK_7761180541142a5926501018d34" PRIMARY KEY (id); + + +-- +-- Name: claim_image PK_7c49e44bfe8840ca7d917890101; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_images + ADD CONSTRAINT "PK_7c49e44bfe8840ca7d917890101" PRIMARY KEY (id); + + +-- +-- Name: customer_group PK_88e7da3ff7262d9e0a35aa3664e; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.customer_groups + ADD CONSTRAINT "PK_88e7da3ff7262d9e0a35aa3664e" PRIMARY KEY (id); + + +-- +-- Name: claim_order PK_8981f5595a4424021466aa4c7a4; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_orders + ADD CONSTRAINT "PK_8981f5595a4424021466aa4c7a4" PRIMARY KEY (id); + + +-- +-- Name: migrations PK_8c82d7f526340ab734260ea46be; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.migrations + ADD CONSTRAINT "PK_8c82d7f526340ab734260ea46be" PRIMARY KEY (id); + + +-- +-- Name: custom_shipping_option PK_8dfcb5c1172c29eec4a728420cc; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.custom_shipping_options + ADD CONSTRAINT "PK_8dfcb5c1172c29eec4a728420cc" PRIMARY KEY (id); + + +-- +-- Name: analytics_config PK_93505647c5d7cb479becb810b0f; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.analytics_configs + ADD CONSTRAINT "PK_93505647c5d7cb479becb810b0f" PRIMARY KEY (id); + + +-- +-- Name: return_reason PK_95fd1172973165790903e65660a; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.return_reasons + ADD CONSTRAINT "PK_95fd1172973165790903e65660a" PRIMARY KEY (id); + + +-- +-- Name: note PK_96d0c172a4fba276b1bbed43058; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.notes + ADD CONSTRAINT "PK_96d0c172a4fba276b1bbed43058" PRIMARY KEY (id); + + +-- +-- Name: discount_condition_product PK_994eb4529fdbf14450d64ec17e8; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_products + ADD CONSTRAINT "PK_994eb4529fdbf14450d64ec17e8" PRIMARY KEY (product_id, condition_id); + + +-- +-- Name: product_variant_inventory_item PK_9a1188b8d36f4d198303b4f7efa; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_variant_inventory_items + ADD CONSTRAINT "PK_9a1188b8d36f4d198303b4f7efa" PRIMARY KEY (id); + + +-- +-- Name: staged_job PK_9a28fb48c46c5509faf43ac8c8d; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.staged_jobs + ADD CONSTRAINT "PK_9a28fb48c46c5509faf43ac8c8d" PRIMARY KEY (id); + + +-- +-- Name: publishable_api_key PK_9e613278673a87de92c606b4494; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.publishable_api_keys + ADD CONSTRAINT "PK_9e613278673a87de92c606b4494" PRIMARY KEY (id); + + +-- +-- Name: region_payment_providers PK_9fa1e69914d3dd752de6b1da407; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.region_payment_providers + ADD CONSTRAINT "PK_9fa1e69914d3dd752de6b1da407" PRIMARY KEY (region_id, provider_id); + + +-- +-- Name: shipping_option_requirement PK_a0ff15442606d9f783602cb23a7; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_option_requirements + ADD CONSTRAINT "PK_a0ff15442606d9f783602cb23a7" PRIMARY KEY (id); + + +-- +-- Name: payment_session PK_a1a91b20f7f3b1e5afb5485cbcd; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_sessions + ADD CONSTRAINT "PK_a1a91b20f7f3b1e5afb5485cbcd" PRIMARY KEY (id); + + +-- +-- Name: order_discounts PK_a7418714ffceebc125bf6d8fcfe; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_discounts + ADD CONSTRAINT "PK_a7418714ffceebc125bf6d8fcfe" PRIMARY KEY (order_id, discount_id); + + +-- +-- Name: customer PK_a7a13f4cacb744524e44dfdad32; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.customers + ADD CONSTRAINT "PK_a7a13f4cacb744524e44dfdad32" PRIMARY KEY (id); + + +-- +-- Name: discount_condition_product_tag PK_a95382c1e62205b121aa058682b; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_product_tags + ADD CONSTRAINT "PK_a95382c1e62205b121aa058682b" PRIMARY KEY (product_tag_id, condition_id); + + +-- +-- Name: oauth PK_a957b894e50eb16b969c0640a8d; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.oauth + ADD CONSTRAINT "PK_a957b894e50eb16b969c0640a8d" PRIMARY KEY (id); + + +-- +-- Name: discount_rule PK_ac2c280de3701b2d66f6817f760; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_rules + ADD CONSTRAINT "PK_ac2c280de3701b2d66f6817f760" PRIMARY KEY (id); + + +-- +-- Name: gift_card PK_af4e338d2d41035042843ad641f; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.gift_cards + ADD CONSTRAINT "PK_af4e338d2d41035042843ad641f" PRIMARY KEY (id); + + +-- +-- Name: sales_channel_location PK_afd2c2c52634bc8280a9c9ee533; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.sales_channel_locations + ADD CONSTRAINT "PK_afd2c2c52634bc8280a9c9ee533" PRIMARY KEY (id); + + +-- +-- Name: tax_provider PK_b198bf82ba6a317c11763d99b99; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.tax_providers + ADD CONSTRAINT "PK_b198bf82ba6a317c11763d99b99" PRIMARY KEY (id); + + +-- +-- Name: discount_condition_product_collection PK_b3508fc787aa4a38705866cbb6d; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_product_collections + ADD CONSTRAINT "PK_b3508fc787aa4a38705866cbb6d" PRIMARY KEY (product_collection_id, condition_id); + + +-- +-- Name: shipping_method PK_b9b0adfad3c6b99229c1e7d4865; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_methods + ADD CONSTRAINT "PK_b9b0adfad3c6b99229c1e7d4865" PRIMARY KEY (id); + + +-- +-- Name: fulfillment_item PK_bc3e8a388de75db146a249922e0; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.fulfillment_items + ADD CONSTRAINT "PK_bc3e8a388de75db146a249922e0" PRIMARY KEY (fulfillment_id, item_id); + + +-- +-- Name: shipping_tax_rate PK_bcd93b14d7e2695365d383f5eae; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_tax_rates + ADD CONSTRAINT "PK_bcd93b14d7e2695365d383f5eae" PRIMARY KEY (shipping_option_id, rate_id); + + +-- +-- Name: fulfillment_provider PK_beb35a6de60a6c4f91d5ae57e44; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.fulfillment_providers + ADD CONSTRAINT "PK_beb35a6de60a6c4f91d5ae57e44" PRIMARY KEY (id); + + +-- +-- Name: product PK_bebc9158e480b949565b4dc7a82; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.products + ADD CONSTRAINT "PK_bebc9158e480b949565b4dc7a82" PRIMARY KEY (id); + + +-- +-- Name: country PK_bf6e37c231c4f4ea56dcd887269; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.countries + ADD CONSTRAINT "PK_bf6e37c231c4f4ea56dcd887269" PRIMARY KEY (id); + + +-- +-- Name: cart PK_c524ec48751b9b5bcfbf6e59be7; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.carts + ADD CONSTRAINT "PK_c524ec48751b9b5bcfbf6e59be7" PRIMARY KEY (id); + + +-- +-- Name: shipping_profile PK_c8120e4543a5a3a121f2968a1ec; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_profiles + ADD CONSTRAINT "PK_c8120e4543a5a3a121f2968a1ec" PRIMARY KEY (id); + + +-- +-- Name: return PK_c8ad68d13e76d75d803b5aeebc4; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.returns + ADD CONSTRAINT "PK_c8ad68d13e76d75d803b5aeebc4" PRIMARY KEY (id); + + +-- +-- Name: user PK_cace4a159ff9f2512dd42373760; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.users + ADD CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY (id); + + +-- +-- Name: line_item PK_cce6b13e67fa506d1d9618ac68b; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_items + ADD CONSTRAINT "PK_cce6b13e67fa506d1d9618ac68b" PRIMARY KEY (id); + + +-- +-- Name: discount_condition_customer_group PK_cdc8b2277169a16b8b7d4c73e0e; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_customer_groups + ADD CONSTRAINT "PK_cdc8b2277169a16b8b7d4c73e0e" PRIMARY KEY (customer_group_id, condition_id); + + +-- +-- Name: gift_card_transaction PK_cfb5b4ba5447a507aef87d73fe7; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.gift_card_transactions + ADD CONSTRAINT "PK_cfb5b4ba5447a507aef87d73fe7" PRIMARY KEY (id); + + +-- +-- Name: discount PK_d05d8712e429673e459e7f1cddb; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discounts + ADD CONSTRAINT "PK_d05d8712e429673e459e7f1cddb" PRIMARY KEY (id); + + +-- +-- Name: sales_channel PK_d1eb0b923ea5a0eb1e0916191f1; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.sales_channels + ADD CONSTRAINT "PK_d1eb0b923ea5a0eb1e0916191f1" PRIMARY KEY (id); + + +-- +-- Name: image PK_d6db1ab4ee9ad9dbe86c64e4cc3; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.images + ADD CONSTRAINT "PK_d6db1ab4ee9ad9dbe86c64e4cc3" PRIMARY KEY (id); + + +-- +-- Name: order_item_change PK_d6eb138f77ffdee83567b85af0c; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_item_changes + ADD CONSTRAINT "PK_d6eb138f77ffdee83567b85af0c" PRIMARY KEY (id); + + +-- +-- Name: address PK_d92de1f82754668b5f5f5dd4fd5; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.addresses + ADD CONSTRAINT "PK_d92de1f82754668b5f5f5dd4fd5" PRIMARY KEY (id); + + +-- +-- Name: product_type_tax_rate PK_ddc9242de1d99bc7674969289f0; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_type_tax_rates + ADD CONSTRAINT "PK_ddc9242de1d99bc7674969289f0" PRIMARY KEY (product_type_id, rate_id); + + +-- +-- Name: product_type PK_e0843930fbb8854fe36ca39dae1; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_types + ADD CONSTRAINT "PK_e0843930fbb8854fe36ca39dae1" PRIMARY KEY (id); + + +-- +-- Name: customer_group_customers PK_e28a55e34ad1e2d3df9a0ac86d3; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.customer_group_customers + ADD CONSTRAINT "PK_e28a55e34ad1e2d3df9a0ac86d3" PRIMARY KEY (customer_group_id, customer_id); + + +-- +-- Name: batch_job PK_e57f84d485145d5be96bc6d871e; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.batch_jobs + ADD CONSTRAINT "PK_e57f84d485145d5be96bc6d871e" PRIMARY KEY (id); + + +-- +-- Name: discount_condition PK_e6b81d83133ddc21a2baf2e2204; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_conditions + ADD CONSTRAINT "PK_e6b81d83133ddc21a2baf2e2204" PRIMARY KEY (id); + + +-- +-- Name: payment_provider PK_ea94f42b6c88e9191c3649d7522; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_providers + ADD CONSTRAINT "PK_ea94f42b6c88e9191c3649d7522" PRIMARY KEY (id); + + +-- +-- Name: refund PK_f1cefa2e60d99b206c46c1116e5; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.refunds + ADD CONSTRAINT "PK_f1cefa2e60d99b206c46c1116e5" PRIMARY KEY (id); + + +-- +-- Name: store PK_f3172007d4de5ae8e7692759d79; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.stores + ADD CONSTRAINT "PK_f3172007d4de5ae8e7692759d79" PRIMARY KEY (id); + + +-- +-- Name: draft_order PK_f478946c183d98f8d88a94cfcd7; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.draft_orders + ADD CONSTRAINT "PK_f478946c183d98f8d88a94cfcd7" PRIMARY KEY (id); + + +-- +-- Name: invite PK_fc9fa190e5a3c5d80604a4f63e1; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.invites + ADD CONSTRAINT "PK_fc9fa190e5a3c5d80604a4f63e1" PRIMARY KEY (id); + + +-- +-- Name: payment PK_fcaec7df5adf9cac408c686b2ab; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payments + ADD CONSTRAINT "PK_fcaec7df5adf9cac408c686b2ab" PRIMARY KEY (id); + + +-- +-- Name: tracking_link PK_fcfd77feb9012ec2126d7c0bfb6; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.tracking_links + ADD CONSTRAINT "PK_fcfd77feb9012ec2126d7c0bfb6" PRIMARY KEY (id); + + +-- +-- Name: product_sales_channel PK_fd29b6a8bd641052628dee19583; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_sales_channels + ADD CONSTRAINT "PK_fd29b6a8bd641052628dee19583" PRIMARY KEY (product_id, sales_channel_id); + + +-- +-- Name: payment_collection PK_payment_collection_id; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_collections + ADD CONSTRAINT "PK_payment_collection_id" PRIMARY KEY (id); + + +-- +-- Name: payment_collection_payments PK_payment_collection_payments; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_collection_payments + ADD CONSTRAINT "PK_payment_collection_payments" PRIMARY KEY (payment_collection_id, payment_id); + + +-- +-- Name: payment_collection_sessions PK_payment_collection_sessions; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_collection_sessions + ADD CONSTRAINT "PK_payment_collection_sessions" PRIMARY KEY (payment_collection_id, payment_session_id); + + +-- +-- Name: product_category PK_qgguwbn1cwstxk93efl0px9oqwt; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_categories + ADD CONSTRAINT "PK_qgguwbn1cwstxk93efl0px9oqwt" PRIMARY KEY (id); + + +-- +-- Name: shipping_method REL_1d9ad62038998c3a85c77a53cf; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_methods + ADD CONSTRAINT "REL_1d9ad62038998c3a85c77a53cf" UNIQUE (return_id); + + +-- +-- Name: swap REL_402e8182bc553e082f6380020b; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.swaps + ADD CONSTRAINT "REL_402e8182bc553e082f6380020b" UNIQUE (cart_id); + + +-- +-- Name: draft_order REL_5bd11d0e2a9628128e2c26fd0a; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.draft_orders + ADD CONSTRAINT "REL_5bd11d0e2a9628128e2c26fd0a" UNIQUE (cart_id); + + +-- +-- Name: order_item_change REL_5f9688929761f7df108b630e64; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_item_changes + ADD CONSTRAINT "REL_5f9688929761f7df108b630e64" UNIQUE (line_item_id); + + +-- +-- Name: customer REL_8abe81b9aac151ae60bf507ad1; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.customers + ADD CONSTRAINT "REL_8abe81b9aac151ae60bf507ad1" UNIQUE (billing_address_id); + + +-- +-- Name: draft_order REL_8f6dd6c49202f1466ebf21e77d; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.draft_orders + ADD CONSTRAINT "REL_8f6dd6c49202f1466ebf21e77d" UNIQUE (order_id); + + +-- +-- Name: cart REL_9d1a161434c610aae7c3df2dc7; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.carts + ADD CONSTRAINT "REL_9d1a161434c610aae7c3df2dc7" UNIQUE (payment_id); + + +-- +-- Name: return REL_bad82d7bff2b08b87094bfac3d; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.returns + ADD CONSTRAINT "REL_bad82d7bff2b08b87094bfac3d" UNIQUE (swap_id); + + +-- +-- Name: payment REL_c17aff091441b7c25ec3d68d36; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payments + ADD CONSTRAINT "REL_c17aff091441b7c25ec3d68d36" UNIQUE (swap_id); + + +-- +-- Name: order REL_c99a206eb11ad45f6b7f04f2dc; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ADD CONSTRAINT "REL_c99a206eb11ad45f6b7f04f2dc" UNIQUE (cart_id); + + +-- +-- Name: custom_shipping_option UQ_0f838b122a9a01d921aa1cdb669; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.custom_shipping_options + ADD CONSTRAINT "UQ_0f838b122a9a01d921aa1cdb669" UNIQUE (shipping_option_id, cart_id); + + +-- +-- Name: line_item_tax_line UQ_3c2af51043ed7243e7d9775a2ad; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_item_tax_lines + ADD CONSTRAINT "UQ_3c2af51043ed7243e7d9775a2ad" UNIQUE (item_id, code); + + +-- +-- Name: order_item_change UQ_5b7a99181e4db2ea821be0b6196; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_item_changes + ADD CONSTRAINT "UQ_5b7a99181e4db2ea821be0b6196" UNIQUE (order_edit_id, original_line_item_id); + + +-- +-- Name: store UQ_61b0f48cccbb5f41c750bac7286; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.stores + ADD CONSTRAINT "UQ_61b0f48cccbb5f41c750bac7286" UNIQUE (default_sales_channel_id); + + +-- +-- Name: return UQ_71773d56eb2bacb922bc3283398; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.returns + ADD CONSTRAINT "UQ_71773d56eb2bacb922bc3283398" UNIQUE (claim_order_id); + + +-- +-- Name: order UQ_727b872f86c7378474a8fa46147; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ADD CONSTRAINT "UQ_727b872f86c7378474a8fa46147" UNIQUE (draft_order_id); + + +-- +-- Name: product_variant_inventory_item UQ_c9be7c1b11a1a729eb51d1b6bca; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_variant_inventory_items + ADD CONSTRAINT "UQ_c9be7c1b11a1a729eb51d1b6bca" UNIQUE (variant_id, inventory_item_id); + + +-- +-- Name: shipping_method_tax_line UQ_cd147fca71e50bc954139fa3104; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_method_tax_lines + ADD CONSTRAINT "UQ_cd147fca71e50bc954139fa3104" UNIQUE (shipping_method_id, code); + + +-- +-- Name: order_item_change UQ_da93cee3ca0dd50a5246268c2e9; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_item_changes + ADD CONSTRAINT "UQ_da93cee3ca0dd50a5246268c2e9" UNIQUE (order_edit_id, line_item_id); + + +-- +-- Name: customer UQ_unique_email_for_guests_and_customer_accounts; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.customers + ADD CONSTRAINT "UQ_unique_email_for_guests_and_customer_accounts" UNIQUE (email, has_account); + + +-- +-- Name: discount_condition dctypeuniq; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_conditions + ADD CONSTRAINT dctypeuniq UNIQUE (type, operator, discount_rule_id); + + +-- +-- Name: gift_card_transaction gcuniq; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.gift_card_transactions + ADD CONSTRAINT gcuniq UNIQUE (gift_card_id, order_id); + + +-- +-- Name: IDX_00605f9d662c06b81c1b60ce24; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_00605f9d662c06b81c1b60ce24" ON public.return_reasons USING btree (value); + + +-- +-- Name: IDX_012a62ba743e427b5ebe9dee18; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_012a62ba743e427b5ebe9dee18" ON public.shipping_option_requirements USING btree (shipping_option_id); + + +-- +-- Name: IDX_01486cc9dc6b36bf658685535f; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_01486cc9dc6b36bf658685535f" ON public.discount_condition_product_tags USING btree (product_tag_id); + + +-- +-- Name: IDX_017d58bf8260c6e1a2588d258e; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_017d58bf8260c6e1a2588d258e" ON public.claim_orders USING btree (shipping_address_id); + + +-- +-- Name: IDX_045d4a149c09f4704e0bc08dd4; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_045d4a149c09f4704e0bc08dd4" ON public.product_variants USING btree (barcode) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_0fb38b6d167793192bc126d835; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_0fb38b6d167793192bc126d835" ON public.cart_gift_cards USING btree (gift_card_id); + + +-- +-- Name: IDX_0fc1ec4e3db9001ad60c19daf1; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_0fc1ec4e3db9001ad60c19daf1" ON public.order_discounts USING btree (discount_id); + + +-- +-- Name: IDX_118e3c48f09a7728f41023c94e; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_118e3c48f09a7728f41023c94e" ON public.line_items USING btree (claim_order_id); + + +-- +-- Name: IDX_19b0c6293443d1b464f604c331; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_19b0c6293443d1b464f604c331" ON public.orders USING btree (shipping_address_id); + + +-- +-- Name: IDX_1d04aebeabb6a89f87e536a124; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_1d04aebeabb6a89f87e536a124" ON public.product_tax_rates USING btree (product_id); + + +-- +-- Name: IDX_1d9ad62038998c3a85c77a53cf; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_1d9ad62038998c3a85c77a53cf" ON public.shipping_methods USING btree (return_id); + + +-- +-- Name: IDX_21683a063fe82dafdf681ecc9c; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_21683a063fe82dafdf681ecc9c" ON public.product_to_tags USING btree (product_tag_id); + + +-- +-- Name: IDX_21cbfedd83d736d86f4c6f4ce5; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_21cbfedd83d736d86f4c6f4ce5" ON public.claim_images USING btree (claim_item_id); + + +-- +-- Name: IDX_2212515ba306c79f42c46a99db; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_2212515ba306c79f42c46a99db" ON public.product_images USING btree (image_id); + + +-- +-- Name: IDX_242205c81c1152fab1b6e84847; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_242205c81c1152fab1b6e84847" ON public.carts USING btree (customer_id); + + +-- +-- Name: IDX_2484cf14c437a04586b07e7ddd; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_2484cf14c437a04586b07e7ddd" ON public.product_tax_rates USING btree (rate_id); + + +-- +-- Name: IDX_25a3138bb236f63d9bb6c8ff11; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_25a3138bb236f63d9bb6c8ff11" ON public.product_type_tax_rates USING btree (product_type_id); + + +-- +-- Name: IDX_27283ee631862266d0f1c68064; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_27283ee631862266d0f1c68064" ON public.line_items USING btree (cart_id); + + +-- +-- Name: IDX_2ca8cfbdafb998ecfd6d340389; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_2ca8cfbdafb998ecfd6d340389" ON public.product_variants USING btree (sku) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_2f41b20a71f30e60471d7e3769; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_2f41b20a71f30e60471d7e3769" ON public.line_item_adjustments USING btree (discount_id); + + +-- +-- Name: IDX_3287f98befad26c3a7dab088cf; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_3287f98befad26c3a7dab088cf" ON public.notes USING btree (resource_id); + + +-- +-- Name: IDX_346e0016cf045b998074774764; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_346e0016cf045b998074774764" ON public.shipping_tax_rates USING btree (rate_id); + + +-- +-- Name: IDX_37341bad297fe5cca91f921032; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_37341bad297fe5cca91f921032" ON public.product_sales_channels USING btree (sales_channel_id); + + +-- +-- Name: IDX_379ca70338ce9991f3affdeedf; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_379ca70338ce9991f3affdeedf" ON public.analytics_configs USING btree (id, user_id) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_37f361c38a18d12a3fa3158d0c; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_37f361c38a18d12a3fa3158d0c" ON public.region_fulfillment_providers USING btree (provider_id); + + +-- +-- Name: IDX_3a6947180aeec283cd92c59ebb; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_3a6947180aeec283cd92c59ebb" ON public.region_payment_providers USING btree (provider_id); + + +-- +-- Name: IDX_3c6412d076292f439269abe1a2; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_3c6412d076292f439269abe1a2" ON public.customer_group_customers USING btree (customer_id); + + +-- +-- Name: IDX_3fa354d8d1233ff81097b2fcb6; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_3fa354d8d1233ff81097b2fcb6" ON public.line_items USING btree (swap_id); + + +-- +-- Name: IDX_43a2b24495fe1d9fc2a9c835bc; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_43a2b24495fe1d9fc2a9c835bc" ON public.line_items USING btree (order_id); + + +-- +-- Name: IDX_44090cb11b06174cbcc667e91c; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_44090cb11b06174cbcc667e91c" ON public.custom_shipping_options USING btree (shipping_option_id); + + +-- +-- Name: IDX_4665f17abc1e81dd58330e5854; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_4665f17abc1e81dd58330e5854" ON public.payments USING btree (cart_id); + + +-- +-- Name: IDX_484c329f4783be4e18e5e2ff09; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_484c329f4783be4e18e5e2ff09" ON public.carts USING btree (region_id); + + +-- +-- Name: IDX_4d5f98645a67545d8dea42e2eb; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_4d5f98645a67545d8dea42e2eb" ON public.discount_condition_customer_groups USING btree (customer_group_id); + + +-- +-- Name: IDX_4e0739e5f0244c08d41174ca08; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_4e0739e5f0244c08d41174ca08" ON public.discount_rule_products USING btree (discount_rule_id); + + +-- +-- Name: IDX_4f166bb8c2bfcef2498d97b406; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_4f166bb8c2bfcef2498d97b406" ON public.product_images USING btree (product_id); + + +-- +-- Name: IDX_5077fa54b0d037e984385dfe8a; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_5077fa54b0d037e984385dfe8a" ON public.line_item_tax_lines USING btree (item_id); + + +-- +-- Name: IDX_5267705a43d547e232535b656c; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_5267705a43d547e232535b656c" ON public.shipping_methods USING btree (order_id); + + +-- +-- Name: IDX_52875734e9dd69064f0041f4d9; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_52875734e9dd69064f0041f4d9" ON public.price_list_customer_groups USING btree (price_list_id); + + +-- +-- Name: IDX_52dd74e8c989aa5665ad2852b8; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_52dd74e8c989aa5665ad2852b8" ON public.swaps USING btree (order_id); + + +-- +-- Name: IDX_5371cbaa3be5200f373d24e3d5; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_5371cbaa3be5200f373d24e3d5" ON public.line_items USING btree (variant_id); + + +-- +-- Name: IDX_53cb5605fa42e82b4d47b47bda; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_53cb5605fa42e82b4d47b47bda" ON public.gift_cards USING btree (code); + + +-- +-- Name: IDX_5568d3b9ce9f7abeeb37511ecf; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_5568d3b9ce9f7abeeb37511ecf" ON public.orders USING btree (billing_address_id); + + +-- +-- Name: IDX_579e01fb94f4f58db480857e05; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_579e01fb94f4f58db480857e05" ON public.orders USING btree (display_id); + + +-- +-- Name: IDX_5a4d5e1e60f97633547821ec8d; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_5a4d5e1e60f97633547821ec8d" ON public.product_sales_channels USING btree (product_id); + + +-- +-- Name: IDX_5b0c6fc53c574299ecc7f9ee22; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_5b0c6fc53c574299ecc7f9ee22" ON public.product_to_tags USING btree (product_id); + + +-- +-- Name: IDX_5bd11d0e2a9628128e2c26fd0a; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_5bd11d0e2a9628128e2c26fd0a" ON public.draft_orders USING btree (cart_id); + + +-- +-- Name: IDX_5c58105f1752fca0f4ce69f466; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_5c58105f1752fca0f4ce69f466" ON public.shipping_options USING btree (region_id); + + +-- +-- Name: IDX_620330964db8d2999e67b0dbe3; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_620330964db8d2999e67b0dbe3" ON public.customer_group_customers USING btree (customer_group_id); + + +-- +-- Name: IDX_64980511ca32c8e92b417644af; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_64980511ca32c8e92b417644af" ON public.claim_items USING btree (variant_id); + + +-- +-- Name: IDX_6680319ebe1f46d18f106191d5; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_6680319ebe1f46d18f106191d5" ON public.cart_discounts USING btree (cart_id); + + +-- +-- Name: IDX_6b0ce4b4bcfd24491510bf19d1; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_6b0ce4b4bcfd24491510bf19d1" ON public.invites USING btree (user_email); + + +-- +-- Name: IDX_6b9c66b5e36f7c827dfaa092f9; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_6b9c66b5e36f7c827dfaa092f9" ON public.carts USING btree (billing_address_id); + + +-- +-- Name: IDX_6e0cad0daef76bb642675910b9; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_6e0cad0daef76bb642675910b9" ON public.claim_items USING btree (item_id); + + +-- +-- Name: IDX_6ef23ce0b1d9cf9b5b833e52b9; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_6ef23ce0b1d9cf9b5b833e52b9" ON public.discount_condition_product_types USING btree (condition_id); + + +-- +-- Name: IDX_6f234f058bbbea810dce1d04d0; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_6f234f058bbbea810dce1d04d0" ON public.product_collections USING btree (handle) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_71773d56eb2bacb922bc328339; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_71773d56eb2bacb922bc328339" ON public.returns USING btree (claim_order_id); + + +-- +-- Name: IDX_80823b7ae866dc5acae2dac6d2; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_80823b7ae866dc5acae2dac6d2" ON public.products USING btree (profile_id); + + +-- +-- Name: IDX_82a6bbb0b527c20a0002ddcbd6; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_82a6bbb0b527c20a0002ddcbd6" ON public.store_currencies USING btree (currency_code); + + +-- +-- Name: IDX_8486ee16e69013c645d0b8716b; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_8486ee16e69013c645d0b8716b" ON public.discount_condition_customer_groups USING btree (condition_id); + + +-- +-- Name: IDX_8aaa78ba90d3802edac317df86; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_8aaa78ba90d3802edac317df86" ON public.region_payment_providers USING btree (region_id); + + +-- +-- Name: IDX_8abe81b9aac151ae60bf507ad1; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_8abe81b9aac151ae60bf507ad1" ON public.customers USING btree (billing_address_id); + + +-- +-- Name: IDX_8df75ef4f35f217768dc113545; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_8df75ef4f35f217768dc113545" ON public.cart_discounts USING btree (discount_id); + + +-- +-- Name: IDX_8f6dd6c49202f1466ebf21e77d; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_8f6dd6c49202f1466ebf21e77d" ON public.draft_orders USING btree (order_id); + + +-- +-- Name: IDX_900a9c3834257304396b2b0fe7; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_900a9c3834257304396b2b0fe7" ON public.claim_items USING btree (claim_order_id); + + +-- +-- Name: IDX_926ca9f29014af8091722dede0; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_926ca9f29014af8091722dede0" ON public.shipping_method_tax_lines USING btree (shipping_method_id); + + +-- +-- Name: IDX_93caeb1bb70d37c1d36d6701a7; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_93caeb1bb70d37c1d36d6701a7" ON public.custom_shipping_options USING btree (cart_id); + + +-- +-- Name: IDX_9c9614b2f9d01665800ea8dbff; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_9c9614b2f9d01665800ea8dbff" ON public.addresses USING btree (customer_id); + + +-- +-- Name: IDX_9d1a161434c610aae7c3df2dc7; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_9d1a161434c610aae7c3df2dc7" ON public.carts USING btree (payment_id); + + +-- +-- Name: IDX_a0b05dc4257abe639cb75f8eae; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_a0b05dc4257abe639cb75f8eae" ON public.discount_condition_product_collections USING btree (product_collection_id); + + +-- +-- Name: IDX_a0e206bfaed3cb63c186091734; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_a0e206bfaed3cb63c186091734" ON public.shipping_options USING btree (provider_id); + + +-- +-- Name: IDX_a1c4f9cfb599ad1f0db39cadd5; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_a1c4f9cfb599ad1f0db39cadd5" ON public.discount_condition_product_collections USING btree (condition_id); + + +-- +-- Name: IDX_a21a7ffbe420d492eb46c305fe; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_a21a7ffbe420d492eb46c305fe" ON public.discount_regions USING btree (region_id); + + +-- +-- Name: IDX_a421bf4588d0004a9b0c0fe84f; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_a421bf4588d0004a9b0c0fe84f" ON public.idempotency_keys USING btree (idempotency_key); + + +-- +-- Name: IDX_a52e234f729db789cf473297a5; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_a52e234f729db789cf473297a5" ON public.fulfillments USING btree (swap_id); + + +-- +-- Name: IDX_aa16f61348be02dd07ce3fc54e; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_aa16f61348be02dd07ce3fc54e" ON public.product_variants USING btree (upc) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_aac4855eadda71aa1e4b6d7684; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_aac4855eadda71aa1e4b6d7684" ON public.payments USING btree (cart_id) WHERE (canceled_at IS NOT NULL); + + +-- +-- Name: IDX_ac2c280de3701b2d66f6817f76; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_ac2c280de3701b2d66f6817f76" ON public.discounts USING btree (rule_id); + + +-- +-- Name: IDX_b1aac8314662fa6b25569a575b; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_b1aac8314662fa6b25569a575b" ON public.countries USING btree (region_id); + + +-- +-- Name: IDX_b4f4b63d1736689b7008980394; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_b4f4b63d1736689b7008980394" ON public.store_currencies USING btree (store_id); + + +-- +-- Name: IDX_b5b6225539ee8501082fbc0714; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_b5b6225539ee8501082fbc0714" ON public.product_variants USING btree (ean) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_b5df0f53a74b9d0c0a2b652c88; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_b5df0f53a74b9d0c0a2b652c88" ON public.notifications USING btree (customer_id); + + +-- +-- Name: IDX_b6bcf8c3903097b84e85154eed; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_b6bcf8c3903097b84e85154eed" ON public.gift_cards USING btree (region_id); + + +-- +-- Name: IDX_ba8de19442d86957a3aa3b5006; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_ba8de19442d86957a3aa3b5006" ON public.users USING btree (email) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_bad82d7bff2b08b87094bfac3d; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_bad82d7bff2b08b87094bfac3d" ON public.returns USING btree (swap_id); + + +-- +-- Name: IDX_be66106a673b88a81c603abe7e; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_be66106a673b88a81c603abe7e" ON public.discount_rule_products USING btree (product_id); + + +-- +-- Name: IDX_be9aea2ccf3567007b6227da4d; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_be9aea2ccf3567007b6227da4d" ON public.line_item_adjustments USING btree (item_id); + + +-- +-- Name: IDX_beb35a6de60a6c4f91d5ae57e4; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_beb35a6de60a6c4f91d5ae57e4" ON public.fulfillments USING btree (provider_id); + + +-- +-- Name: IDX_bf701b88d2041392a288785ada; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_bf701b88d2041392a288785ada" ON public.line_item_adjustments USING btree (discount_id, item_id) WHERE (discount_id IS NOT NULL); + + +-- +-- Name: IDX_c17aff091441b7c25ec3d68d36; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_c17aff091441b7c25ec3d68d36" ON public.payments USING btree (swap_id); + + +-- +-- Name: IDX_c2c0f3edf39515bd15432afe6e; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_c2c0f3edf39515bd15432afe6e" ON public.claim_item_tags USING btree (item_id); + + +-- +-- Name: IDX_c49c061b1a686843c5d673506f; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_c49c061b1a686843c5d673506f" ON public.oauth USING btree (application_name); + + +-- +-- Name: IDX_c4c3a5225a7a1f0af782c40abc; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_c4c3a5225a7a1f0af782c40abc" ON public.customer_groups USING btree (name) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_c5516f550433c9b1c2630d787a; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_c5516f550433c9b1c2630d787a" ON public.price_list_customer_groups USING btree (customer_group_id); + + +-- +-- Name: IDX_c556e14eff4d6f03db593df955; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_c556e14eff4d6f03db593df955" ON public.region_fulfillment_providers USING btree (region_id); + + +-- +-- Name: IDX_c759f53b2e48e8cfb50638fe4e; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_c759f53b2e48e8cfb50638fe4e" ON public.discount_condition_products USING btree (product_id); + + +-- +-- Name: IDX_c951439af4c98bf2bd7fb8726c; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_c951439af4c98bf2bd7fb8726c" ON public.shipping_options USING btree (profile_id); + + +-- +-- Name: IDX_c99a206eb11ad45f6b7f04f2dc; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_c99a206eb11ad45f6b7f04f2dc" ON public.orders USING btree (cart_id); + + +-- +-- Name: IDX_ca67dd080aac5ecf99609960cd; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_ca67dd080aac5ecf99609960cd" ON public.product_variants USING btree (product_id); + + +-- +-- Name: IDX_cd7812c96209c5bdd48a6b858b; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_cd7812c96209c5bdd48a6b858b" ON public.orders USING btree (customer_id); + + +-- +-- Name: IDX_ced15a9a695d2b5db9dabce763; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_ced15a9a695d2b5db9dabce763" ON public.carts USING btree (shipping_address_id); + + +-- +-- Name: IDX_cf9cc6c3f2e6414b992223fff1; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_cf9cc6c3f2e6414b992223fff1" ON public.products USING btree (handle) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_d18ad72f2fb7c87f075825b6f8; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_d18ad72f2fb7c87f075825b6f8" ON public.payment_sessions USING btree (provider_id); + + +-- +-- Name: IDX_d25ba0787e1510ddc5d442ebcf; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_d25ba0787e1510ddc5d442ebcf" ON public.payment_sessions USING btree (cart_id); + + +-- +-- Name: IDX_d38047a90f3d42f0be7909e8ae; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_d38047a90f3d42f0be7909e8ae" ON public.cart_gift_cards USING btree (cart_id); + + +-- +-- Name: IDX_d4bd17f918fc6c332b74a368c3; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_d4bd17f918fc6c332b74a368c3" ON public.returns USING btree (order_id); + + +-- +-- Name: IDX_d73e55964e0ff2db8f03807d52; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_d73e55964e0ff2db8f03807d52" ON public.fulfillments USING btree (claim_order_id); + + +-- +-- Name: IDX_d783a66d1c91c0858752c933e6; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_d783a66d1c91c0858752c933e6" ON public.shipping_methods USING btree (claim_order_id); + + +-- +-- Name: IDX_d7d441b81012f87d4265fa57d2; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_d7d441b81012f87d4265fa57d2" ON public.gift_card_transactions USING btree (order_id); + + +-- +-- Name: IDX_d92993a7d554d84571f4eea1d1; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_d92993a7d554d84571f4eea1d1" ON public.shipping_methods USING btree (cart_id); + + +-- +-- Name: IDX_dc9bbf9fcb9ba458d25d512811; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_dc9bbf9fcb9ba458d25d512811" ON public.claim_item_tags USING btree (tag_id); + + +-- +-- Name: IDX_df1494d263740fcfb1d09a98fc; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_df1494d263740fcfb1d09a98fc" ON public.notifications USING btree (resource_type); + + +-- +-- Name: IDX_dfc1f02bb0552e79076aa58dbb; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_dfc1f02bb0552e79076aa58dbb" ON public.gift_cards USING btree (order_id); + + +-- +-- Name: IDX_e1fcce2b18dbcdbe0a5ba9a68b; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_e1fcce2b18dbcdbe0a5ba9a68b" ON public.orders USING btree (region_id); + + +-- +-- Name: IDX_e62ff11e4730bb3adfead979ee; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_e62ff11e4730bb3adfead979ee" ON public.order_gift_cards USING btree (order_id); + + +-- +-- Name: IDX_e706deb68f52ab2756119b9e70; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_e706deb68f52ab2756119b9e70" ON public.discount_condition_product_types USING btree (product_type_id); + + +-- +-- Name: IDX_e78901b1131eaf8203d9b1cb5f; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_e78901b1131eaf8203d9b1cb5f" ON public.countries USING btree (iso_2); + + +-- +-- Name: IDX_e7b488cebe333f449398769b2c; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_e7b488cebe333f449398769b2c" ON public.order_discounts USING btree (order_id); + + +-- +-- Name: IDX_e87cc617a22ef4edce5601edab; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_e87cc617a22ef4edce5601edab" ON public.draft_orders USING btree (display_id); + + +-- +-- Name: IDX_ea6a358d9ce41c16499aae55f9; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_ea6a358d9ce41c16499aae55f9" ON public.notifications USING btree (resource_id); + + +-- +-- Name: IDX_ea94f42b6c88e9191c3649d752; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_ea94f42b6c88e9191c3649d752" ON public.payments USING btree (provider_id); + + +-- +-- Name: IDX_ec10c54769877840c132260e4a; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_ec10c54769877840c132260e4a" ON public.claim_tags USING btree (value); + + +-- +-- Name: IDX_ece65a774192b34253abc4cd67; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_ece65a774192b34253abc4cd67" ON public.product_type_tax_rates USING btree (rate_id); + + +-- +-- Name: IDX_eec9d9af4ca098e19ea6b499ea; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_eec9d9af4ca098e19ea6b499ea" ON public.refunds USING btree (order_id); + + +-- +-- Name: IDX_efff700651718e452ca9580a62; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_efff700651718e452ca9580a62" ON public.discount_conditions USING btree (discount_rule_id); + + +-- +-- Name: IDX_f05132301e95bdab4ba1cf29a2; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_f05132301e95bdab4ba1cf29a2" ON public.discount_condition_products USING btree (condition_id); + + +-- +-- Name: IDX_f129acc85e346a10eed12b86fc; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_f129acc85e346a10eed12b86fc" ON public.fulfillments USING btree (order_id); + + +-- +-- Name: IDX_f2bb9f71e95b315eb24b2b84cb; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_f2bb9f71e95b315eb24b2b84cb" ON public.order_gift_cards USING btree (gift_card_id); + + +-- +-- Name: IDX_f4194aa81073f3fab8aa86906f; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_f4194aa81073f3fab8aa86906f" ON public.discount_regions USING btree (discount_id); + + +-- +-- Name: IDX_f49e3974465d3c3a33d449d3f3; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_f49e3974465d3c3a33d449d3f3" ON public.claim_orders USING btree (order_id); + + +-- +-- Name: IDX_f5221735ace059250daac9d980; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_f5221735ace059250daac9d980" ON public.payments USING btree (order_id); + + +-- +-- Name: IDX_f65bf52e2239ace276ece2b2f4; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_f65bf52e2239ace276ece2b2f4" ON public.discounts USING btree (code) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_f672727ab020df6c50fb64c1a7; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_f672727ab020df6c50fb64c1a7" ON public.shipping_tax_rates USING btree (shipping_option_id); + + +-- +-- Name: IDX_f74980b411cf94af523a72af7d; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_f74980b411cf94af523a72af7d" ON public.notes USING btree (resource_type); + + +-- +-- Name: IDX_fb94fa8d5ca940daa2a58139f8; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_fb94fa8d5ca940daa2a58139f8" ON public.shipping_methods USING btree (swap_id); + + +-- +-- Name: IDX_fbb2499551ed074526f3ee3624; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_fbb2499551ed074526f3ee3624" ON public.discount_condition_product_tags USING btree (condition_id); + + +-- +-- Name: IDX_fc963e94854bff2714ca84cd19; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_fc963e94854bff2714ca84cd19" ON public.shipping_methods USING btree (shipping_option_id); + + +-- +-- Name: IDX_money_amount_currency_code; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_money_amount_currency_code" ON public.money_amounts USING btree (currency_code); + + +-- +-- Name: IDX_order_currency_code; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_order_currency_code" ON public.orders USING btree (currency_code); + + +-- +-- Name: IDX_order_edit_order_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_order_edit_order_id" ON public.order_edits USING btree (order_id); + + +-- +-- Name: IDX_order_edit_payment_collection_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_order_edit_payment_collection_id" ON public.order_edits USING btree (payment_collection_id); + + +-- +-- Name: IDX_payment_collection_currency_code; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_payment_collection_currency_code" ON public.payment_collections USING btree (currency_code) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_payment_collection_payments_payment_collection_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_payment_collection_payments_payment_collection_id" ON public.payment_collection_payments USING btree (payment_collection_id); + + +-- +-- Name: IDX_payment_collection_payments_payment_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_payment_collection_payments_payment_id" ON public.payment_collection_payments USING btree (payment_id); + + +-- +-- Name: IDX_payment_collection_region_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_payment_collection_region_id" ON public.payment_collections USING btree (region_id) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_payment_collection_sessions_payment_collection_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_payment_collection_sessions_payment_collection_id" ON public.payment_collection_sessions USING btree (payment_collection_id); + + +-- +-- Name: IDX_payment_collection_sessions_payment_session_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_payment_collection_sessions_payment_session_id" ON public.payment_collection_sessions USING btree (payment_session_id); + + +-- +-- Name: IDX_payment_currency_code; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_payment_currency_code" ON public.payments USING btree (currency_code); + + +-- +-- Name: IDX_pcp_product_category_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_pcp_product_category_id" ON public.product_category_products USING btree (product_category_id); + + +-- +-- Name: IDX_pcp_product_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_pcp_product_id" ON public.product_category_products USING btree (product_id); + + +-- +-- Name: IDX_product_category_active_public; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_product_category_active_public" ON public.product_categories USING btree (parent_category_id, is_active, is_internal) WHERE ((is_active IS TRUE) AND (is_internal IS FALSE)); + + +-- +-- Name: IDX_product_category_handle; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_product_category_handle" ON public.product_categories USING btree (handle); + + +-- +-- Name: IDX_product_category_path; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_product_category_path" ON public.product_categories USING btree (mpath); + + +-- +-- Name: IDX_product_variant_inventory_item_inventory_item_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_product_variant_inventory_item_inventory_item_id" ON public.product_variant_inventory_items USING btree (inventory_item_id) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_product_variant_inventory_item_variant_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_product_variant_inventory_item_variant_id" ON public.product_variant_inventory_items USING btree (variant_id) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_refund_payment_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_refund_payment_id" ON public.refunds USING btree (payment_id); + + +-- +-- Name: IDX_region_currency_code; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_region_currency_code" ON public.regions USING btree (currency_code); + + +-- +-- Name: IDX_sales_channel_location_location_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_sales_channel_location_location_id" ON public.sales_channel_locations USING btree (location_id) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_sales_channel_location_sales_channel_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX "IDX_sales_channel_location_sales_channel_id" ON public.sales_channel_locations USING btree (sales_channel_id) WHERE (deleted_at IS NULL); + + +-- +-- Name: IDX_upcp_product_id_product_category_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "IDX_upcp_product_id_product_category_id" ON public.product_category_products USING btree (product_category_id, product_id); + + +-- +-- Name: UniqPaymentSessionCartIdProviderId; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "UniqPaymentSessionCartIdProviderId" ON public.payment_sessions USING btree (cart_id, provider_id) WHERE (cart_id IS NOT NULL); + + +-- +-- Name: UniqProductCategoryParentIdRank; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "UniqProductCategoryParentIdRank" ON public.product_categories USING btree (parent_category_id, rank); + + +-- +-- Name: UniquePaymentActive; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX "UniquePaymentActive" ON public.payments USING btree (cart_id) WHERE (canceled_at IS NULL); + + +-- +-- Name: idx_gin_product_collection; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_gin_product_collection ON public.product_collections USING gin (title public.gin_trgm_ops) WHERE (deleted_at IS NULL); + + +-- +-- Name: idx_gin_product_description; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_gin_product_description ON public.products USING gin (description public.gin_trgm_ops) WHERE (deleted_at IS NULL); + + +-- +-- Name: idx_gin_product_title; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_gin_product_title ON public.products USING gin (title public.gin_trgm_ops) WHERE (deleted_at IS NULL); + + +-- +-- Name: idx_gin_product_variant_sku; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_gin_product_variant_sku ON public.product_variants USING gin (sku public.gin_trgm_ops) WHERE (deleted_at IS NULL); + + +-- +-- Name: idx_gin_product_variant_title; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_gin_product_variant_title ON public.product_variants USING gin (title public.gin_trgm_ops) WHERE (deleted_at IS NULL); + + +-- +-- Name: idx_money_amount_region_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_money_amount_region_id ON public.money_amounts USING btree (region_id); + + +-- +-- Name: idx_money_amount_variant_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_money_amount_variant_id ON public.money_amounts USING btree (variant_id); + + +-- +-- Name: idx_product_option_value_option_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_product_option_value_option_id ON public.product_option_values USING btree (option_id); + + +-- +-- Name: idx_product_option_value_variant_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE INDEX idx_product_option_value_variant_id ON public.product_option_values USING btree (variant_id); + + +-- +-- Name: unique_li_original_item_id_order_edit_id; Type: INDEX; Schema: public; Owner: postgres +-- + +CREATE UNIQUE INDEX unique_li_original_item_id_order_edit_id ON public.line_items USING btree (order_edit_id, original_item_id) WHERE ((original_item_id IS NOT NULL) AND (order_edit_id IS NOT NULL)); + + +-- +-- Name: shipping_option_requirement FK_012a62ba743e427b5ebe9dee18e; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_option_requirements + ADD CONSTRAINT "FK_012a62ba743e427b5ebe9dee18e" FOREIGN KEY (shipping_option_id) REFERENCES public.shipping_options (id); + + +-- +-- Name: discount_condition_product_tag FK_01486cc9dc6b36bf658685535f6; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_product_tags + ADD CONSTRAINT "FK_01486cc9dc6b36bf658685535f6" FOREIGN KEY (product_tag_id) REFERENCES public.product_tags (id) ON DELETE CASCADE; + + +-- +-- Name: claim_order FK_017d58bf8260c6e1a2588d258e2; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_orders + ADD CONSTRAINT "FK_017d58bf8260c6e1a2588d258e2" FOREIGN KEY (shipping_address_id) REFERENCES public.addresses (id); + + +-- +-- Name: notification FK_0425c2423e2ce9fdfd5c23761d9; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.notifications + ADD CONSTRAINT "FK_0425c2423e2ce9fdfd5c23761d9" FOREIGN KEY (provider_id) REFERENCES public.notification_providers (id); + + +-- +-- Name: cart_gift_cards FK_0fb38b6d167793192bc126d835e; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.cart_gift_cards + ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY (gift_card_id) REFERENCES public.gift_cards (id) ON DELETE CASCADE; + + +-- +-- Name: order_discounts FK_0fc1ec4e3db9001ad60c19daf16; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_discounts + ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY (discount_id) REFERENCES public.discounts (id) ON DELETE CASCADE; + + +-- +-- Name: line_item FK_118e3c48f09a7728f41023c94ef; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_items + ADD CONSTRAINT "FK_118e3c48f09a7728f41023c94ef" FOREIGN KEY (claim_order_id) REFERENCES public.claim_orders (id); + + +-- +-- Name: money_amount FK_17a06d728e4cfbc5bd2ddb70af0; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.money_amounts + ADD CONSTRAINT "FK_17a06d728e4cfbc5bd2ddb70af0" FOREIGN KEY (variant_id) REFERENCES public.product_variants (id) ON DELETE CASCADE; + + +-- +-- Name: order FK_19b0c6293443d1b464f604c3316; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ADD CONSTRAINT "FK_19b0c6293443d1b464f604c3316" FOREIGN KEY (shipping_address_id) REFERENCES public.addresses (id); + + +-- +-- Name: product_tax_rate FK_1d04aebeabb6a89f87e536a124d; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_tax_rates + ADD CONSTRAINT "FK_1d04aebeabb6a89f87e536a124d" FOREIGN KEY (product_id) REFERENCES public.products (id) ON DELETE CASCADE; + + +-- +-- Name: shipping_method FK_1d9ad62038998c3a85c77a53cfb; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_methods + ADD CONSTRAINT "FK_1d9ad62038998c3a85c77a53cfb" FOREIGN KEY (return_id) REFERENCES public.returns (id); + + +-- +-- Name: order_edit FK_1f3a251488a91510f57e1bf93cd; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_edits + ADD CONSTRAINT "FK_1f3a251488a91510f57e1bf93cd" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: product_tags FK_21683a063fe82dafdf681ecc9c4; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_to_tags + ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY (product_tag_id) REFERENCES public.product_tags (id) ON DELETE CASCADE; + + +-- +-- Name: claim_image FK_21cbfedd83d736d86f4c6f4ce56; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_images + ADD CONSTRAINT "FK_21cbfedd83d736d86f4c6f4ce56" FOREIGN KEY (claim_item_id) REFERENCES public.claim_items (id); + + +-- +-- Name: product_images FK_2212515ba306c79f42c46a99db7; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_images + ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY (image_id) REFERENCES public.images (id) ON DELETE CASCADE; + + +-- +-- Name: return_reason FK_2250c5d9e975987ab212f61a657; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.return_reasons + ADD CONSTRAINT "FK_2250c5d9e975987ab212f61a657" FOREIGN KEY (parent_return_reason_id) REFERENCES public.return_reasons (id); + + +-- +-- Name: discount FK_2250c5d9e975987ab212f61a663; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discounts + ADD CONSTRAINT "FK_2250c5d9e975987ab212f61a663" FOREIGN KEY (parent_discount_id) REFERENCES public.discounts (id); + + +-- +-- Name: cart FK_242205c81c1152fab1b6e848470; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.carts + ADD CONSTRAINT "FK_242205c81c1152fab1b6e848470" FOREIGN KEY (customer_id) REFERENCES public.customers (id); + + +-- +-- Name: product_tax_rate FK_2484cf14c437a04586b07e7dddb; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_tax_rates + ADD CONSTRAINT "FK_2484cf14c437a04586b07e7dddb" FOREIGN KEY (rate_id) REFERENCES public.tax_rates (id) ON DELETE CASCADE; + + +-- +-- Name: product_type_tax_rate FK_25a3138bb236f63d9bb6c8ff111; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_type_tax_rates + ADD CONSTRAINT "FK_25a3138bb236f63d9bb6c8ff111" FOREIGN KEY (product_type_id) REFERENCES public.product_types (id) ON DELETE CASCADE; + + +-- +-- Name: line_item FK_27283ee631862266d0f1c680646; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_items + ADD CONSTRAINT "FK_27283ee631862266d0f1c680646" FOREIGN KEY (cart_id) REFERENCES public.carts (id); + + +-- +-- Name: line_item_adjustment FK_2f41b20a71f30e60471d7e3769c; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_item_adjustments + ADD CONSTRAINT "FK_2f41b20a71f30e60471d7e3769c" FOREIGN KEY (discount_id) REFERENCES public.discounts (id); + + +-- +-- Name: shipping_tax_rate FK_346e0016cf045b9980747747645; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_tax_rates + ADD CONSTRAINT "FK_346e0016cf045b9980747747645" FOREIGN KEY (rate_id) REFERENCES public.tax_rates (id) ON DELETE CASCADE; + + +-- +-- Name: notification FK_371db513192c083f48ba63c33be; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.notifications + ADD CONSTRAINT "FK_371db513192c083f48ba63c33be" FOREIGN KEY (parent_id) REFERENCES public.notifications (id); + + +-- +-- Name: product_sales_channel FK_37341bad297fe5cca91f921032b; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_sales_channels + ADD CONSTRAINT "FK_37341bad297fe5cca91f921032b" FOREIGN KEY (sales_channel_id) REFERENCES public.sales_channels (id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: region_fulfillment_providers FK_37f361c38a18d12a3fa3158d0cf; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.region_fulfillment_providers + ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY (provider_id) REFERENCES public.fulfillment_providers (id) ON DELETE CASCADE; + + +-- +-- Name: region_payment_providers FK_3a6947180aeec283cd92c59ebb0; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.region_payment_providers + ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY (provider_id) REFERENCES public.payment_providers (id) ON DELETE CASCADE; + + +-- +-- Name: region FK_3bdd5896ec93be2f1c62a3309a5; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.regions + ADD CONSTRAINT "FK_3bdd5896ec93be2f1c62a3309a5" FOREIGN KEY (currency_code) REFERENCES public.currencies (code); + + +-- +-- Name: customer_group_customers FK_3c6412d076292f439269abe1a23; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.customer_group_customers + ADD CONSTRAINT "FK_3c6412d076292f439269abe1a23" FOREIGN KEY (customer_id) REFERENCES public.customers (id) ON DELETE CASCADE; + + +-- +-- Name: line_item FK_3fa354d8d1233ff81097b2fcb6b; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_items + ADD CONSTRAINT "FK_3fa354d8d1233ff81097b2fcb6b" FOREIGN KEY (swap_id) REFERENCES public.swaps (id); + + +-- +-- Name: gift_card_transaction FK_3ff5597f1d7e02bba41541846f4; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.gift_card_transactions + ADD CONSTRAINT "FK_3ff5597f1d7e02bba41541846f4" FOREIGN KEY (gift_card_id) REFERENCES public.gift_cards (id); + + +-- +-- Name: swap FK_402e8182bc553e082f6380020b4; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.swaps + ADD CONSTRAINT "FK_402e8182bc553e082f6380020b4" FOREIGN KEY (cart_id) REFERENCES public.carts (id); + + +-- +-- Name: line_item FK_43a2b24495fe1d9fc2a9c835bc7; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_items + ADD CONSTRAINT "FK_43a2b24495fe1d9fc2a9c835bc7" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: custom_shipping_option FK_44090cb11b06174cbcc667e91ca; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.custom_shipping_options + ADD CONSTRAINT "FK_44090cb11b06174cbcc667e91ca" FOREIGN KEY (shipping_option_id) REFERENCES public.shipping_options (id); + + +-- +-- Name: order_item_change FK_44feeebb258bf4cfa4cc4202281; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_item_changes + ADD CONSTRAINT "FK_44feeebb258bf4cfa4cc4202281" FOREIGN KEY (order_edit_id) REFERENCES public.order_edits (id); + + +-- +-- Name: payment FK_4665f17abc1e81dd58330e58542; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payments + ADD CONSTRAINT "FK_4665f17abc1e81dd58330e58542" FOREIGN KEY (cart_id) REFERENCES public.carts (id); + + +-- +-- Name: tracking_link FK_471e9e4c96e02ba209a307db32b; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.tracking_links + ADD CONSTRAINT "FK_471e9e4c96e02ba209a307db32b" FOREIGN KEY (fulfillment_id) REFERENCES public.fulfillments (id); + + +-- +-- Name: cart FK_484c329f4783be4e18e5e2ff090; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.carts + ADD CONSTRAINT "FK_484c329f4783be4e18e5e2ff090" FOREIGN KEY (region_id) REFERENCES public.regions (id); + + +-- +-- Name: product FK_49d419fc77d3aed46c835c558ac; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.products + ADD CONSTRAINT "FK_49d419fc77d3aed46c835c558ac" FOREIGN KEY (collection_id) REFERENCES public.product_collections (id); + + +-- +-- Name: discount_condition_customer_group FK_4d5f98645a67545d8dea42e2eb8; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_customer_groups + ADD CONSTRAINT "FK_4d5f98645a67545d8dea42e2eb8" FOREIGN KEY (customer_group_id) REFERENCES public.customer_groups (id) ON DELETE CASCADE; + + +-- +-- Name: discount_rule_products FK_4e0739e5f0244c08d41174ca08a; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_rule_products + ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY (discount_rule_id) REFERENCES public.discount_rules (id) ON DELETE CASCADE; + + +-- +-- Name: product_images FK_4f166bb8c2bfcef2498d97b4068; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_images + ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY (product_id) REFERENCES public.products (id) ON DELETE CASCADE; + + +-- +-- Name: line_item_tax_line FK_5077fa54b0d037e984385dfe8ad; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_item_tax_lines + ADD CONSTRAINT "FK_5077fa54b0d037e984385dfe8ad" FOREIGN KEY (item_id) REFERENCES public.line_items (id); + + +-- +-- Name: shipping_method FK_5267705a43d547e232535b656c2; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_methods + ADD CONSTRAINT "FK_5267705a43d547e232535b656c2" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: price_list_customer_groups FK_52875734e9dd69064f0041f4d92; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.price_list_customer_groups + ADD CONSTRAINT "FK_52875734e9dd69064f0041f4d92" FOREIGN KEY (price_list_id) REFERENCES public.price_lists (id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: swap FK_52dd74e8c989aa5665ad2852b8b; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.swaps + ADD CONSTRAINT "FK_52dd74e8c989aa5665ad2852b8b" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: line_item FK_5371cbaa3be5200f373d24e3d5b; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_items + ADD CONSTRAINT "FK_5371cbaa3be5200f373d24e3d5b" FOREIGN KEY (variant_id) REFERENCES public.product_variants (id); + + +-- +-- Name: order FK_5568d3b9ce9f7abeeb37511ecf2; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ADD CONSTRAINT "FK_5568d3b9ce9f7abeeb37511ecf2" FOREIGN KEY (billing_address_id) REFERENCES public.addresses (id); + + +-- +-- Name: store FK_55beebaa09e947cccca554af222; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.stores + ADD CONSTRAINT "FK_55beebaa09e947cccca554af222" FOREIGN KEY (default_currency_code) REFERENCES public.currencies (code); + + +-- +-- Name: product_sales_channel FK_5a4d5e1e60f97633547821ec8d6; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_sales_channels + ADD CONSTRAINT "FK_5a4d5e1e60f97633547821ec8d6" FOREIGN KEY (product_id) REFERENCES public.products (id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- +-- Name: product_tags FK_5b0c6fc53c574299ecc7f9ee22e; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_to_tags + ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY (product_id) REFERENCES public.products (id) ON DELETE CASCADE; + + +-- +-- Name: draft_order FK_5bd11d0e2a9628128e2c26fd0a6; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.draft_orders + ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY (cart_id) REFERENCES public.carts (id); + + +-- +-- Name: shipping_option FK_5c58105f1752fca0f4ce69f4663; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_options + ADD CONSTRAINT "FK_5c58105f1752fca0f4ce69f4663" FOREIGN KEY (region_id) REFERENCES public.regions (id); + + +-- +-- Name: order_item_change FK_5f9688929761f7df108b630e64a; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_item_changes + ADD CONSTRAINT "FK_5f9688929761f7df108b630e64a" FOREIGN KEY (line_item_id) REFERENCES public.line_items (id); + + +-- +-- Name: store FK_61b0f48cccbb5f41c750bac7286; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.stores + ADD CONSTRAINT "FK_61b0f48cccbb5f41c750bac7286" FOREIGN KEY (default_sales_channel_id) REFERENCES public.sales_channels (id); + + +-- +-- Name: customer_group_customers FK_620330964db8d2999e67b0dbe3e; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.customer_group_customers + ADD CONSTRAINT "FK_620330964db8d2999e67b0dbe3e" FOREIGN KEY (customer_group_id) REFERENCES public.customer_groups (id) ON DELETE CASCADE; + + +-- +-- Name: claim_item FK_64980511ca32c8e92b417644afa; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_items + ADD CONSTRAINT "FK_64980511ca32c8e92b417644afa" FOREIGN KEY (variant_id) REFERENCES public.product_variants (id); + + +-- +-- Name: cart_discounts FK_6680319ebe1f46d18f106191d59; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.cart_discounts + ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY (cart_id) REFERENCES public.carts (id) ON DELETE CASCADE; + + +-- +-- Name: cart FK_6b9c66b5e36f7c827dfaa092f94; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.carts + ADD CONSTRAINT "FK_6b9c66b5e36f7c827dfaa092f94" FOREIGN KEY (billing_address_id) REFERENCES public.addresses (id); + + +-- +-- Name: address FK_6df8c6bf969a51d24c1980c4ff4; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.addresses + ADD CONSTRAINT "FK_6df8c6bf969a51d24c1980c4ff4" FOREIGN KEY (country_code) REFERENCES public.countries (iso_2); + + +-- +-- Name: claim_item FK_6e0cad0daef76bb642675910b9d; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_items + ADD CONSTRAINT "FK_6e0cad0daef76bb642675910b9d" FOREIGN KEY (item_id) REFERENCES public.line_items (id); + + +-- +-- Name: discount_condition_product_type FK_6ef23ce0b1d9cf9b5b833e52b9d; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_product_types + ADD CONSTRAINT "FK_6ef23ce0b1d9cf9b5b833e52b9d" FOREIGN KEY (condition_id) REFERENCES public.discount_conditions (id) ON DELETE CASCADE; + + +-- +-- Name: order FK_6ff7e874f01b478c115fdd462eb; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ADD CONSTRAINT "FK_6ff7e874f01b478c115fdd462eb" FOREIGN KEY (sales_channel_id) REFERENCES public.sales_channels (id); + + +-- +-- Name: return FK_71773d56eb2bacb922bc3283398; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.returns + ADD CONSTRAINT "FK_71773d56eb2bacb922bc3283398" FOREIGN KEY (claim_order_id) REFERENCES public.claim_orders (id); + + +-- +-- Name: order FK_717a141f96b76d794d409f38129; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ADD CONSTRAINT "FK_717a141f96b76d794d409f38129" FOREIGN KEY (currency_code) REFERENCES public.currencies (code); + + +-- +-- Name: product_option_value FK_7234ed737ff4eb1b6ae6e6d7b01; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_option_values + ADD CONSTRAINT "FK_7234ed737ff4eb1b6ae6e6d7b01" FOREIGN KEY (variant_id) REFERENCES public.product_variants (id) ON DELETE CASCADE; + + +-- +-- Name: order FK_727b872f86c7378474a8fa46147; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ADD CONSTRAINT "FK_727b872f86c7378474a8fa46147" FOREIGN KEY (draft_order_id) REFERENCES public.draft_orders (id); + + +-- +-- Name: return_item FK_7edab75b4fc88ea6d4f2574f087; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.return_items + ADD CONSTRAINT "FK_7edab75b4fc88ea6d4f2574f087" FOREIGN KEY (return_id) REFERENCES public.returns (id); + + +-- +-- Name: product FK_80823b7ae866dc5acae2dac6d2c; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.products + ADD CONSTRAINT "FK_80823b7ae866dc5acae2dac6d2c" FOREIGN KEY (profile_id) REFERENCES public.shipping_profiles (id); + + +-- +-- Name: store_currencies FK_82a6bbb0b527c20a0002ddcbd60; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.store_currencies + ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY (currency_code) REFERENCES public.currencies (code) ON DELETE CASCADE; + + +-- +-- Name: discount_condition_customer_group FK_8486ee16e69013c645d0b8716b6; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_customer_groups + ADD CONSTRAINT "FK_8486ee16e69013c645d0b8716b6" FOREIGN KEY (condition_id) REFERENCES public.discount_conditions (id) ON DELETE CASCADE; + + +-- +-- Name: return_item FK_87774591f44564effd8039d7162; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.return_items + ADD CONSTRAINT "FK_87774591f44564effd8039d7162" FOREIGN KEY (item_id) REFERENCES public.line_items (id); + + +-- +-- Name: region_payment_providers FK_8aaa78ba90d3802edac317df869; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.region_payment_providers + ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY (region_id) REFERENCES public.regions (id) ON DELETE CASCADE; + + +-- +-- Name: customer FK_8abe81b9aac151ae60bf507ad15; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.customers + ADD CONSTRAINT "FK_8abe81b9aac151ae60bf507ad15" FOREIGN KEY (billing_address_id) REFERENCES public.addresses (id); + + +-- +-- Name: cart_discounts FK_8df75ef4f35f217768dc1135458; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.cart_discounts + ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY (discount_id) REFERENCES public.discounts (id) ON DELETE CASCADE; + + +-- +-- Name: draft_order FK_8f6dd6c49202f1466ebf21e77da; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.draft_orders + ADD CONSTRAINT "FK_8f6dd6c49202f1466ebf21e77da" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: claim_item FK_900a9c3834257304396b2b0fe7c; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_items + ADD CONSTRAINT "FK_900a9c3834257304396b2b0fe7c" FOREIGN KEY (claim_order_id) REFERENCES public.claim_orders (id); + + +-- +-- Name: region FK_91f88052197680f9790272aaf5b; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.regions + ADD CONSTRAINT "FK_91f88052197680f9790272aaf5b" FOREIGN KEY (tax_provider_id) REFERENCES public.tax_providers (id); + + +-- +-- Name: shipping_method_tax_line FK_926ca9f29014af8091722dede08; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_method_tax_lines + ADD CONSTRAINT "FK_926ca9f29014af8091722dede08" FOREIGN KEY (shipping_method_id) REFERENCES public.shipping_methods (id); + + +-- +-- Name: custom_shipping_option FK_93caeb1bb70d37c1d36d6701a7a; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.custom_shipping_options + ADD CONSTRAINT "FK_93caeb1bb70d37c1d36d6701a7a" FOREIGN KEY (cart_id) REFERENCES public.carts (id); + + +-- +-- Name: address FK_9c9614b2f9d01665800ea8dbff7; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.addresses + ADD CONSTRAINT "FK_9c9614b2f9d01665800ea8dbff7" FOREIGN KEY (customer_id) REFERENCES public.customers (id); + + +-- +-- Name: cart FK_9d1a161434c610aae7c3df2dc7e; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.carts + ADD CONSTRAINT "FK_9d1a161434c610aae7c3df2dc7e" FOREIGN KEY (payment_id) REFERENCES public.payments (id); + + +-- +-- Name: fulfillment_item FK_a033f83cc6bd7701a5687ab4b38; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.fulfillment_items + ADD CONSTRAINT "FK_a033f83cc6bd7701a5687ab4b38" FOREIGN KEY (fulfillment_id) REFERENCES public.fulfillments (id); + + +-- +-- Name: discount_condition_product_collection FK_a0b05dc4257abe639cb75f8eae2; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_product_collections + ADD CONSTRAINT "FK_a0b05dc4257abe639cb75f8eae2" FOREIGN KEY (product_collection_id) REFERENCES public.product_collections (id) ON DELETE CASCADE; + + +-- +-- Name: shipping_option FK_a0e206bfaed3cb63c1860917347; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_options + ADD CONSTRAINT "FK_a0e206bfaed3cb63c1860917347" FOREIGN KEY (provider_id) REFERENCES public.fulfillment_providers (id); + + +-- +-- Name: discount_condition_product_collection FK_a1c4f9cfb599ad1f0db39cadd5f; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_product_collections + ADD CONSTRAINT "FK_a1c4f9cfb599ad1f0db39cadd5f" FOREIGN KEY (condition_id) REFERENCES public.discount_conditions (id) ON DELETE CASCADE; + + +-- +-- Name: discount_regions FK_a21a7ffbe420d492eb46c305fec; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_regions + ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY (region_id) REFERENCES public.regions (id) ON DELETE CASCADE; + + +-- +-- Name: cart FK_a2bd3c26f42e754b9249ba78fd6; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.carts + ADD CONSTRAINT "FK_a2bd3c26f42e754b9249ba78fd6" FOREIGN KEY (sales_channel_id) REFERENCES public.sales_channels (id); + + +-- +-- Name: fulfillment FK_a52e234f729db789cf473297a5c; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.fulfillments + ADD CONSTRAINT "FK_a52e234f729db789cf473297a5c" FOREIGN KEY (swap_id) REFERENCES public.swaps (id); + + +-- +-- Name: discount FK_ac2c280de3701b2d66f6817f760; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discounts + ADD CONSTRAINT "FK_ac2c280de3701b2d66f6817f760" FOREIGN KEY (rule_id) REFERENCES public.discount_rules (id); + + +-- +-- Name: country FK_b1aac8314662fa6b25569a575bb; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.countries + ADD CONSTRAINT "FK_b1aac8314662fa6b25569a575bb" FOREIGN KEY (region_id) REFERENCES public.regions (id); + + +-- +-- Name: money_amount FK_b433e27b7a83e6d12ab26b15b03; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.money_amounts + ADD CONSTRAINT "FK_b433e27b7a83e6d12ab26b15b03" FOREIGN KEY (region_id) REFERENCES public.regions (id); + + +-- +-- Name: order_item_change FK_b4d53b8d03c9f5e7d4317e818d9; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_item_changes + ADD CONSTRAINT "FK_b4d53b8d03c9f5e7d4317e818d9" FOREIGN KEY (original_line_item_id) REFERENCES public.line_items (id); + + +-- +-- Name: store_currencies FK_b4f4b63d1736689b7008980394c; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.store_currencies + ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY (store_id) REFERENCES public.stores (id) ON DELETE CASCADE; + + +-- +-- Name: notification FK_b5df0f53a74b9d0c0a2b652c88d; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.notifications + ADD CONSTRAINT "FK_b5df0f53a74b9d0c0a2b652c88d" FOREIGN KEY (customer_id) REFERENCES public.customers (id); + + +-- +-- Name: gift_card FK_b6bcf8c3903097b84e85154eed3; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.gift_cards + ADD CONSTRAINT "FK_b6bcf8c3903097b84e85154eed3" FOREIGN KEY (region_id) REFERENCES public.regions (id); + + +-- +-- Name: tax_rate FK_b95a1e03b051993d208366cb960; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.tax_rates + ADD CONSTRAINT "FK_b95a1e03b051993d208366cb960" FOREIGN KEY (region_id) REFERENCES public.regions (id); + + +-- +-- Name: return FK_bad82d7bff2b08b87094bfac3d6; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.returns + ADD CONSTRAINT "FK_bad82d7bff2b08b87094bfac3d6" FOREIGN KEY (swap_id) REFERENCES public.swaps (id); + + +-- +-- Name: discount_rule_products FK_be66106a673b88a81c603abe7eb; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_rule_products + ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY (product_id) REFERENCES public.products (id) ON DELETE CASCADE; + + +-- +-- Name: line_item_adjustment FK_be9aea2ccf3567007b6227da4d2; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_item_adjustments + ADD CONSTRAINT "FK_be9aea2ccf3567007b6227da4d2" FOREIGN KEY (item_id) REFERENCES public.line_items (id) ON DELETE CASCADE; + + +-- +-- Name: fulfillment FK_beb35a6de60a6c4f91d5ae57e44; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.fulfillments + ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY (provider_id) REFERENCES public.fulfillment_providers (id); + + +-- +-- Name: payment FK_c17aff091441b7c25ec3d68d36c; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payments + ADD CONSTRAINT "FK_c17aff091441b7c25ec3d68d36c" FOREIGN KEY (swap_id) REFERENCES public.swaps (id); + + +-- +-- Name: claim_item_tags FK_c2c0f3edf39515bd15432afe6e5; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_item_tags + ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY (item_id) REFERENCES public.claim_items (id) ON DELETE CASCADE; + + +-- +-- Name: price_list_customer_groups FK_c5516f550433c9b1c2630d787a7; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.price_list_customer_groups + ADD CONSTRAINT "FK_c5516f550433c9b1c2630d787a7" FOREIGN KEY (customer_group_id) REFERENCES public.customer_groups (id) ON DELETE CASCADE; + + +-- +-- Name: region_fulfillment_providers FK_c556e14eff4d6f03db593df955e; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.region_fulfillment_providers + ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY (region_id) REFERENCES public.regions (id) ON DELETE CASCADE; + + +-- +-- Name: discount_condition_product FK_c759f53b2e48e8cfb50638fe4e0; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_products + ADD CONSTRAINT "FK_c759f53b2e48e8cfb50638fe4e0" FOREIGN KEY (product_id) REFERENCES public.products (id) ON DELETE CASCADE; + + +-- +-- Name: shipping_option FK_c951439af4c98bf2bd7fb8726cd; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_options + ADD CONSTRAINT "FK_c951439af4c98bf2bd7fb8726cd" FOREIGN KEY (profile_id) REFERENCES public.shipping_profiles (id); + + +-- +-- Name: order FK_c99a206eb11ad45f6b7f04f2dcc; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ADD CONSTRAINT "FK_c99a206eb11ad45f6b7f04f2dcc" FOREIGN KEY (cart_id) REFERENCES public.carts (id); + + +-- +-- Name: product_variant FK_ca67dd080aac5ecf99609960cd2; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_variants + ADD CONSTRAINT "FK_ca67dd080aac5ecf99609960cd2" FOREIGN KEY (product_id) REFERENCES public.products (id); + + +-- +-- Name: order FK_cd7812c96209c5bdd48a6b858b0; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ADD CONSTRAINT "FK_cd7812c96209c5bdd48a6b858b0" FOREIGN KEY (customer_id) REFERENCES public.customers (id); + + +-- +-- Name: product_option_value FK_cdf4388f294b30a25c627d69fe9; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_option_values + ADD CONSTRAINT "FK_cdf4388f294b30a25c627d69fe9" FOREIGN KEY (option_id) REFERENCES public.product_options (id); + + +-- +-- Name: cart FK_ced15a9a695d2b5db9dabce763d; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.carts + ADD CONSTRAINT "FK_ced15a9a695d2b5db9dabce763d" FOREIGN KEY (shipping_address_id) REFERENCES public.addresses (id); + + +-- +-- Name: payment_session FK_d25ba0787e1510ddc5d442ebcfa; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_sessions + ADD CONSTRAINT "FK_d25ba0787e1510ddc5d442ebcfa" FOREIGN KEY (cart_id) REFERENCES public.carts (id); + + +-- +-- Name: cart_gift_cards FK_d38047a90f3d42f0be7909e8aea; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.cart_gift_cards + ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY (cart_id) REFERENCES public.carts (id) ON DELETE CASCADE; + + +-- +-- Name: return FK_d4bd17f918fc6c332b74a368c36; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.returns + ADD CONSTRAINT "FK_d4bd17f918fc6c332b74a368c36" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: fulfillment FK_d73e55964e0ff2db8f03807d52e; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.fulfillments + ADD CONSTRAINT "FK_d73e55964e0ff2db8f03807d52e" FOREIGN KEY (claim_order_id) REFERENCES public.claim_orders (id); + + +-- +-- Name: return_item FK_d742532378a65022e7ceb328828; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.return_items + ADD CONSTRAINT "FK_d742532378a65022e7ceb328828" FOREIGN KEY (reason_id) REFERENCES public.return_reasons (id); + + +-- +-- Name: shipping_method FK_d783a66d1c91c0858752c933e68; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_methods + ADD CONSTRAINT "FK_d783a66d1c91c0858752c933e68" FOREIGN KEY (claim_order_id) REFERENCES public.claim_orders (id); + + +-- +-- Name: gift_card_transaction FK_d7d441b81012f87d4265fa57d24; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.gift_card_transactions + ADD CONSTRAINT "FK_d7d441b81012f87d4265fa57d24" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: shipping_method FK_d92993a7d554d84571f4eea1d13; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_methods + ADD CONSTRAINT "FK_d92993a7d554d84571f4eea1d13" FOREIGN KEY (cart_id) REFERENCES public.carts (id); + + +-- +-- Name: claim_item_tags FK_dc9bbf9fcb9ba458d25d512811b; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_item_tags + ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY (tag_id) REFERENCES public.claim_tags (id) ON DELETE CASCADE; + + +-- +-- Name: gift_card FK_dfc1f02bb0552e79076aa58dbb0; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.gift_cards + ADD CONSTRAINT "FK_dfc1f02bb0552e79076aa58dbb0" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: product FK_e0843930fbb8854fe36ca39dae1; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.products + ADD CONSTRAINT "FK_e0843930fbb8854fe36ca39dae1" FOREIGN KEY (type_id) REFERENCES public.product_types (id); + + +-- +-- Name: fulfillment_item FK_e13ff60e74206b747a1896212d1; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.fulfillment_items + ADD CONSTRAINT "FK_e13ff60e74206b747a1896212d1" FOREIGN KEY (item_id) REFERENCES public.line_items (id); + + +-- +-- Name: money_amount FK_e15811f81339e4bd8c440aebe1c; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.money_amounts + ADD CONSTRAINT "FK_e15811f81339e4bd8c440aebe1c" FOREIGN KEY (currency_code) REFERENCES public.currencies (code); + + +-- +-- Name: order FK_e1fcce2b18dbcdbe0a5ba9a68b8; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.orders + ADD CONSTRAINT "FK_e1fcce2b18dbcdbe0a5ba9a68b8" FOREIGN KEY (region_id) REFERENCES public.regions (id); + + +-- +-- Name: order_gift_cards FK_e62ff11e4730bb3adfead979ee2; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_gift_cards + ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY (order_id) REFERENCES public.orders (id) ON DELETE CASCADE; + + +-- +-- Name: product_option FK_e634fca34f6b594b87fdbee95f6; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_options + ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY (product_id) REFERENCES public.products (id); + + +-- +-- Name: discount_condition_product_type FK_e706deb68f52ab2756119b9e704; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_product_types + ADD CONSTRAINT "FK_e706deb68f52ab2756119b9e704" FOREIGN KEY (product_type_id) REFERENCES public.product_types (id) ON DELETE CASCADE; + + +-- +-- Name: order_discounts FK_e7b488cebe333f449398769b2cc; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_discounts + ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY (order_id) REFERENCES public.orders (id) ON DELETE CASCADE; + + +-- +-- Name: product_type_tax_rate FK_ece65a774192b34253abc4cd672; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_type_tax_rates + ADD CONSTRAINT "FK_ece65a774192b34253abc4cd672" FOREIGN KEY (rate_id) REFERENCES public.tax_rates (id) ON DELETE CASCADE; + + +-- +-- Name: refund FK_eec9d9af4ca098e19ea6b499eaa; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.refunds + ADD CONSTRAINT "FK_eec9d9af4ca098e19ea6b499eaa" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: discount_condition FK_efff700651718e452ca9580a624; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_conditions + ADD CONSTRAINT "FK_efff700651718e452ca9580a624" FOREIGN KEY (discount_rule_id) REFERENCES public.discount_rules (id); + + +-- +-- Name: discount_condition_product FK_f05132301e95bdab4ba1cf29a24; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_products + ADD CONSTRAINT "FK_f05132301e95bdab4ba1cf29a24" FOREIGN KEY (condition_id) REFERENCES public.discount_conditions (id) ON DELETE CASCADE; + + +-- +-- Name: fulfillment FK_f129acc85e346a10eed12b86fca; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.fulfillments + ADD CONSTRAINT "FK_f129acc85e346a10eed12b86fca" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: money_amount FK_f249976b079375499662eb80c40; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.money_amounts + ADD CONSTRAINT "FK_f249976b079375499662eb80c40" FOREIGN KEY (price_list_id) REFERENCES public.price_lists (id) ON DELETE CASCADE; + + +-- +-- Name: order_gift_cards FK_f2bb9f71e95b315eb24b2b84cb3; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_gift_cards + ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY (gift_card_id) REFERENCES public.gift_cards (id) ON DELETE CASCADE; + + +-- +-- Name: payment FK_f41553459a4b1491c9893ebc921; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payments + ADD CONSTRAINT "FK_f41553459a4b1491c9893ebc921" FOREIGN KEY (currency_code) REFERENCES public.currencies (code); + + +-- +-- Name: discount_regions FK_f4194aa81073f3fab8aa86906ff; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_regions + ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY (discount_id) REFERENCES public.discounts (id) ON DELETE CASCADE; + + +-- +-- Name: claim_order FK_f49e3974465d3c3a33d449d3f31; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.claim_orders + ADD CONSTRAINT "FK_f49e3974465d3c3a33d449d3f31" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: swap FK_f5189d38b3d3bd496618bf54c57; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.swaps + ADD CONSTRAINT "FK_f5189d38b3d3bd496618bf54c57" FOREIGN KEY (shipping_address_id) REFERENCES public.addresses (id); + + +-- +-- Name: payment FK_f5221735ace059250daac9d9803; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payments + ADD CONSTRAINT "FK_f5221735ace059250daac9d9803" FOREIGN KEY (order_id) REFERENCES public.orders (id); + + +-- +-- Name: shipping_tax_rate FK_f672727ab020df6c50fb64c1a70; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_tax_rates + ADD CONSTRAINT "FK_f672727ab020df6c50fb64c1a70" FOREIGN KEY (shipping_option_id) REFERENCES public.shipping_options (id) ON DELETE CASCADE; + + +-- +-- Name: batch_job FK_fa53ca4f5fd90605b532802a626; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.batch_jobs + ADD CONSTRAINT "FK_fa53ca4f5fd90605b532802a626" FOREIGN KEY (created_by) REFERENCES public.users (id); + + +-- +-- Name: shipping_method FK_fb94fa8d5ca940daa2a58139f86; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_methods + ADD CONSTRAINT "FK_fb94fa8d5ca940daa2a58139f86" FOREIGN KEY (swap_id) REFERENCES public.swaps (id); + + +-- +-- Name: discount_condition_product_tag FK_fbb2499551ed074526f3ee36241; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.discount_condition_product_tags + ADD CONSTRAINT "FK_fbb2499551ed074526f3ee36241" FOREIGN KEY (condition_id) REFERENCES public.discount_conditions (id) ON DELETE CASCADE; + + +-- +-- Name: shipping_method FK_fc963e94854bff2714ca84cd193; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.shipping_methods + ADD CONSTRAINT "FK_fc963e94854bff2714ca84cd193" FOREIGN KEY (shipping_option_id) REFERENCES public.shipping_options (id); + + +-- +-- Name: order_edit FK_order_edit_payment_collection_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.order_edits + ADD CONSTRAINT "FK_order_edit_payment_collection_id" FOREIGN KEY (payment_collection_id) REFERENCES public.payment_collections (id); + + +-- +-- Name: payment_collection_payments FK_payment_collection_payments_payment_collection_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_collection_payments + ADD CONSTRAINT "FK_payment_collection_payments_payment_collection_id" FOREIGN KEY (payment_collection_id) REFERENCES public.payment_collections (id) ON DELETE CASCADE; + + +-- +-- Name: payment_collection_payments FK_payment_collection_payments_payment_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_collection_payments + ADD CONSTRAINT "FK_payment_collection_payments_payment_id" FOREIGN KEY (payment_id) REFERENCES public.payments (id) ON DELETE CASCADE; + + +-- +-- Name: payment_collection FK_payment_collection_region_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_collections + ADD CONSTRAINT "FK_payment_collection_region_id" FOREIGN KEY (region_id) REFERENCES public.regions (id); + + +-- +-- Name: payment_collection_sessions FK_payment_collection_sessions_payment_collection_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_collection_sessions + ADD CONSTRAINT "FK_payment_collection_sessions_payment_collection_id" FOREIGN KEY (payment_collection_id) REFERENCES public.payment_collections (id) ON DELETE CASCADE; + + +-- +-- Name: payment_collection_sessions FK_payment_collection_sessions_payment_session_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.payment_collection_sessions + ADD CONSTRAINT "FK_payment_collection_sessions_payment_session_id" FOREIGN KEY (payment_session_id) REFERENCES public.payment_sessions (id) ON DELETE CASCADE; + + +-- +-- Name: product_category_product FK_product_category_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_category_products + ADD CONSTRAINT "FK_product_category_id" FOREIGN KEY (product_category_id) REFERENCES public.product_categories (id) ON DELETE CASCADE; + + +-- +-- Name: product_category_product FK_product_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.product_category_products + ADD CONSTRAINT "FK_product_id" FOREIGN KEY (product_id) REFERENCES public.products (id) ON DELETE CASCADE; + + +-- +-- Name: refund FK_refund_payment_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.refunds + ADD CONSTRAINT "FK_refund_payment_id" FOREIGN KEY (payment_id) REFERENCES public.payments (id); + + +-- +-- Name: line_item line_item_order_edit_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_items + ADD CONSTRAINT line_item_order_edit_fk FOREIGN KEY (order_edit_id) REFERENCES public.order_edits (id); + + +-- +-- Name: line_item line_item_original_item_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.line_items + ADD CONSTRAINT line_item_original_item_fk FOREIGN KEY (original_item_id) REFERENCES public.line_items (id); diff --git a/scripts/build-adapters b/scripts/build-adapters index 44e32e4..dbf9aab 100755 --- a/scripts/build-adapters +++ b/scripts/build-adapters @@ -1,12 +1,15 @@ #!/usr/bin/env zsh -target=wasm32-wasi -#target=wasm32-unknown-unknown +set -ex -mkdir -p adapters -for d in $(ls crates | grep payment_adapter_); do -# echo $d - echo "cargo build --target ${target} -p ${d} --manifest-path ./crates/${d}/Cargo.toml" - cargo build --target-dir ./target --target ${target} -p ${d} --manifest-path ./crates/$d/Cargo.toml - cp ./target/${target}/debug/${d}.wasm ./adapters/ +rm -Rf plugins/available + +mkdir -p plugins/enabled +mkdir -p plugins/available + +for d in $(ls crates | grep -e '-plugin'); do + echo "cargo build --manifest-path ./crates/${d}/Cargo.toml" + cargo build --manifest-path ./crates/${d}/Cargo.toml done + +cp ./target/${target}/debug/*.so ./plugins/available diff --git a/scripts/generate-migrations b/scripts/generate-migrations new file mode 100755 index 0000000..3af926d --- /dev/null +++ b/scripts/generate-migrations @@ -0,0 +1,12 @@ +#!/usr/bin/env zsh + +NAME=$1 +if [[ "$1" == "" ]]; +then + echo "Name is required" + exit 1 +fi +DATE=$(date +'%Y%m%d%H%M%S') + +touch migrations/${DATE}_${NAME}.sql +#touch migrations/${DATE}_${NAME}_down.sql diff --git a/scripts/generate-models b/scripts/generate-models new file mode 100755 index 0000000..f27aacb --- /dev/null +++ b/scripts/generate-models @@ -0,0 +1,4 @@ +#!/usr/bin/env zsh + +rm ./crates/model/v4/*.rs +sea generate entity -v --with-serde=both --expanded-format -o ./crates/model/src/v4