WIP: Añade nueva extensión para dar soporte a bases de datos #12

Draft
manuelcillero wants to merge 12 commits from pagetop-seaorm-support into main
9 changed files with 227 additions and 331 deletions
Showing only changes of commit aa931ea052 - Show all commits

353
Cargo.lock generated
View file

@ -88,7 +88,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -222,7 +222,7 @@ dependencies = [
"actix-router", "actix-router",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -273,7 +273,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"getrandom 0.3.4",
"once_cell", "once_cell",
"version_check", "version_check",
"zerocopy", "zerocopy",
@ -535,7 +534,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -552,7 +551,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -582,12 +581,6 @@ version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5"
[[package]]
name = "base64"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]] [[package]]
name = "base64" name = "base64"
version = "0.22.1" version = "0.22.1"
@ -1036,7 +1029,7 @@ dependencies = [
"ident_case", "ident_case",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -1047,7 +1040,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead"
dependencies = [ dependencies = [
"darling_core", "darling_core",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -1080,7 +1073,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"rustc_version", "rustc_version",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -1102,7 +1095,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"rustc_version", "rustc_version",
"syn 2.0.117", "syn",
"unicode-xid", "unicode-xid",
] ]
@ -1137,7 +1130,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -1146,18 +1139,6 @@ version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
[[package]]
name = "educe"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4bd92664bf78c4d3dba9b7cdafce6fa15b13ed3ed16175218196942e99168a8"
dependencies = [
"enum-ordinalize",
"proc-macro2",
"quote",
"syn 2.0.117",
]
[[package]] [[package]]
name = "either" name = "either"
version = "1.15.0" version = "1.15.0"
@ -1176,26 +1157,6 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "enum-ordinalize"
version = "4.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a1091a7bb1f8f2c4b28f1fe2cef4980ca2d410a3d727d67ecc3178c9b0800f0"
dependencies = [
"enum-ordinalize-derive",
]
[[package]]
name = "enum-ordinalize-derive"
version = "4.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ca9601fb2d62598ee17836250842873a413586e5d7ed88b356e38ddbb0ec631"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.117",
]
[[package]] [[package]]
name = "equivalent" name = "equivalent"
version = "1.0.2" version = "1.0.2"
@ -1322,7 +1283,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54f0d287c53ffd184d04d8677f590f4ac5379785529e5e08b1c8083acdd5c198" checksum = "54f0d287c53ffd184d04d8677f590f4ac5379785529e5e08b1c8083acdd5c198"
dependencies = [ dependencies = [
"memchr", "memchr",
"thiserror 2.0.18", "thiserror",
] ]
[[package]] [[package]]
@ -1335,7 +1296,7 @@ dependencies = [
"ignore", "ignore",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
"unic-langid", "unic-langid",
] ]
@ -1353,7 +1314,7 @@ dependencies = [
"ignore", "ignore",
"intl-memoizer", "intl-memoizer",
"log", "log",
"thiserror 2.0.18", "thiserror",
"unic-langid", "unic-langid",
] ]
@ -1499,7 +1460,7 @@ checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -1588,7 +1549,7 @@ checksum = "c43d815f896a3c730f0d76b8348a1700dc8d8fd6c377e4590d531bdd646574d8"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -1692,6 +1653,8 @@ version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [ dependencies = [
"allocator-api2",
"equivalent",
"foldhash", "foldhash",
] ]
@ -1703,11 +1666,11 @@ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
[[package]] [[package]]
name = "hashlink" name = "hashlink"
version = "0.8.4" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
dependencies = [ dependencies = [
"hashbrown 0.14.5", "hashbrown 0.15.5",
] ]
[[package]] [[package]]
@ -1715,9 +1678,6 @@ name = "heck"
version = "0.4.1" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
dependencies = [
"unicode-segmentation",
]
[[package]] [[package]]
name = "heck" name = "heck"
@ -1998,7 +1958,7 @@ checksum = "c727f80bfa4a6c6e2508d2f05b6f4bfce242030bd88ed15ae5331c5b5d30fba7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -2148,9 +2108,9 @@ dependencies = [
[[package]] [[package]]
name = "libsqlite3-sys" name = "libsqlite3-sys"
version = "0.27.0" version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149"
dependencies = [ dependencies = [
"cc", "cc",
"pkg-config", "pkg-config",
@ -2251,12 +2211,6 @@ dependencies = [
"unicase", "unicase",
] ]
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.8.9" version = "0.8.9"
@ -2302,16 +2256,6 @@ dependencies = [
"tempfile", "tempfile",
] ]
[[package]]
name = "nom"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]] [[package]]
name = "nu-ansi-term" name = "nu-ansi-term"
version = "0.50.3" version = "0.50.3"
@ -2413,7 +2357,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -2436,18 +2380,18 @@ dependencies = [
[[package]] [[package]]
name = "ordered-float" name = "ordered-float"
version = "3.9.2" version = "4.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951"
dependencies = [ dependencies = [
"num-traits", "num-traits",
] ]
[[package]] [[package]]
name = "ouroboros" name = "ouroboros"
version = "0.17.2" version = "0.18.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2ba07320d39dfea882faa70554b4bd342a5f273ed59ba7c1c6b4c840492c954" checksum = "1e0f050db9c44b97a94723127e6be766ac5c340c48f2c4bb3ffa11713744be59"
dependencies = [ dependencies = [
"aliasable", "aliasable",
"ouroboros_macro", "ouroboros_macro",
@ -2456,15 +2400,15 @@ dependencies = [
[[package]] [[package]]
name = "ouroboros_macro" name = "ouroboros_macro"
version = "0.17.2" version = "0.18.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec4c6225c69b4ca778c0aea097321a64c421cf4577b331c61b229267edabb6f8" checksum = "3c7028bdd3d43083f6d8d4d5187680d0d3560d54df4cc9d752005268b41e64d0"
dependencies = [ dependencies = [
"heck 0.4.1", "heck 0.4.1",
"proc-macro-error",
"proc-macro2", "proc-macro2",
"proc-macro2-diagnostics",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -2533,7 +2477,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"proc-macro2-diagnostics", "proc-macro2-diagnostics",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -2599,12 +2543,6 @@ dependencies = [
"windows-link", "windows-link",
] ]
[[package]]
name = "paste"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]] [[package]]
name = "pastey" name = "pastey"
version = "0.2.2" version = "0.2.2"
@ -2683,7 +2621,7 @@ dependencies = [
"phf_shared", "phf_shared",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -2712,7 +2650,7 @@ checksum = "a990e22f43e84855daf260dded30524ef4a9021cc7541c26540500a50b624389"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -2844,31 +2782,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"syn 2.0.117", "syn",
]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn 1.0.109",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
"version_check",
] ]
[[package]] [[package]]
@ -2890,7 +2804,7 @@ dependencies = [
"proc-macro-error-attr2", "proc-macro-error-attr2",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -2916,8 +2830,9 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
"version_check", "version_check",
"yansi",
] ]
[[package]] [[package]]
@ -3178,18 +3093,19 @@ dependencies = [
"proc-macro-error2", "proc-macro-error2",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
name = "sea-orm" name = "sea-orm"
version = "1.0.1" version = "1.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea1fee0cf8528dbe6eda29d5798afc522a63b75e44c5b15721e6e64af9c7cc4b" checksum = "2dc312fedd460a47ea563911761d254a84e7b51d8cc73ec92c929e78f33fa957"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
"futures", "derive_more 2.1.1",
"futures-util",
"log", "log",
"ouroboros", "ouroboros",
"sea-orm-macros", "sea-orm-macros",
@ -3198,32 +3114,31 @@ dependencies = [
"serde", "serde",
"sqlx", "sqlx",
"strum", "strum",
"thiserror 1.0.69", "thiserror",
"tracing", "tracing",
"url", "url",
] ]
[[package]] [[package]]
name = "sea-orm-macros" name = "sea-orm-macros"
version = "1.0.1" version = "1.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8737b566799ed0444f278d13c300c4c6f1a91782f60ff5825a591852d5502030" checksum = "9b9a3f90e336ec74803e8eb98c61bc98754c1adfba3b4f84d946237b752b1c88"
dependencies = [ dependencies = [
"heck 0.4.1", "heck 0.5.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"sea-bae", "sea-bae",
"syn 2.0.117", "syn",
"unicode-ident", "unicode-ident",
] ]
[[package]] [[package]]
name = "sea-query" name = "sea-query"
version = "0.31.1" version = "0.32.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4fd043b8117af233e221f73e3ea8dfbc8e8c3c928017c474296db45c649105c" checksum = "8a5d1c518eaf5eda38e5773f902b26ab6d5e9e9e2bb2349ca6c64cf96f80448c"
dependencies = [ dependencies = [
"educe",
"inherent", "inherent",
"ordered-float", "ordered-float",
"sea-query-derive", "sea-query-derive",
@ -3231,9 +3146,9 @@ dependencies = [
[[package]] [[package]]
name = "sea-query-binder" name = "sea-query-binder"
version = "0.6.0" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "754965d4aee6145bec25d0898e5c931e6c22859789ce62fd85a42a15ed5a8ce3" checksum = "b0019f47430f7995af63deda77e238c17323359af241233ec768aba1faea7608"
dependencies = [ dependencies = [
"sea-query", "sea-query",
"sqlx", "sqlx",
@ -3249,15 +3164,15 @@ dependencies = [
"heck 0.4.1", "heck 0.4.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
"thiserror 2.0.18", "thiserror",
] ]
[[package]] [[package]]
name = "sea-schema" name = "sea-schema"
version = "0.15.0" version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad52149fc81836ea7424c3425d8f6ed8ad448dd16d2e4f6a3907ba46f3f2fd78" checksum = "2239ff574c04858ca77485f112afea1a15e53135d3097d0c86509cef1def1338"
dependencies = [ dependencies = [
"futures", "futures",
"sea-query", "sea-query",
@ -3273,7 +3188,7 @@ dependencies = [
"heck 0.4.1", "heck 0.4.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -3338,7 +3253,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -3466,6 +3381,9 @@ name = "smallvec"
version = "1.15.1" version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "socket2" name = "socket2"
@ -3516,21 +3434,11 @@ dependencies = [
"der", "der",
] ]
[[package]]
name = "sqlformat"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bba3a93db0cc4f7bdece8bb09e77e2e785c20bfebf79eb8340ed80708048790"
dependencies = [
"nom",
"unicode_categories",
]
[[package]] [[package]]
name = "sqlx" name = "sqlx"
version = "0.7.4" version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9a2ccff1a000a5a59cd33da541d9f2fdcd9e6e8229cc200565942bff36d0aaa" checksum = "1fefb893899429669dcdd979aff487bd78f4064e5e7907e4269081e0ef7d97dc"
dependencies = [ dependencies = [
"sqlx-core", "sqlx-core",
"sqlx-macros", "sqlx-macros",
@ -3541,67 +3449,62 @@ dependencies = [
[[package]] [[package]]
name = "sqlx-core" name = "sqlx-core"
version = "0.7.4" version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24ba59a9342a3d9bab6c56c118be528b27c9b60e490080e9711a04dccac83ef6" checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6"
dependencies = [ dependencies = [
"ahash",
"async-io 1.13.0", "async-io 1.13.0",
"async-std", "async-std",
"atoi", "base64 0.22.1",
"byteorder",
"bytes", "bytes",
"crc", "crc",
"crossbeam-queue", "crossbeam-queue",
"either", "either",
"event-listener 2.5.3", "event-listener 5.4.1",
"futures-channel",
"futures-core", "futures-core",
"futures-intrusive", "futures-intrusive",
"futures-io", "futures-io",
"futures-util", "futures-util",
"hashbrown 0.15.5",
"hashlink", "hashlink",
"hex",
"indexmap", "indexmap",
"log", "log",
"memchr", "memchr",
"native-tls", "native-tls",
"once_cell", "once_cell",
"paste",
"percent-encoding", "percent-encoding",
"serde", "serde",
"serde_json", "serde_json",
"sha2", "sha2",
"smallvec", "smallvec",
"sqlformat", "thiserror",
"thiserror 1.0.69",
"tracing", "tracing",
"url", "url",
] ]
[[package]] [[package]]
name = "sqlx-macros" name = "sqlx-macros"
version = "0.7.4" version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ea40e2345eb2faa9e1e5e326db8c34711317d2b5e08d0d5741619048a803127" checksum = "a2d452988ccaacfbf5e0bdbc348fb91d7c8af5bee192173ac3636b5fb6e6715d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"sqlx-core", "sqlx-core",
"sqlx-macros-core", "sqlx-macros-core",
"syn 1.0.109", "syn",
] ]
[[package]] [[package]]
name = "sqlx-macros-core" name = "sqlx-macros-core"
version = "0.7.4" version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5833ef53aaa16d860e92123292f1f6a3d53c34ba8b1969f152ef1a7bb803f3c8" checksum = "19a9c1841124ac5a61741f96e1d9e2ec77424bf323962dd894bdb93f37d5219b"
dependencies = [ dependencies = [
"async-std", "async-std",
"dotenvy", "dotenvy",
"either", "either",
"heck 0.4.1", "heck 0.5.0",
"hex", "hex",
"once_cell", "once_cell",
"proc-macro2", "proc-macro2",
@ -3613,19 +3516,18 @@ dependencies = [
"sqlx-mysql", "sqlx-mysql",
"sqlx-postgres", "sqlx-postgres",
"sqlx-sqlite", "sqlx-sqlite",
"syn 1.0.109", "syn",
"tempfile",
"url", "url",
] ]
[[package]] [[package]]
name = "sqlx-mysql" name = "sqlx-mysql"
version = "0.7.4" version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ed31390216d20e538e447a7a9b959e06ed9fc51c37b514b46eb758016ecd418" checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526"
dependencies = [ dependencies = [
"atoi", "atoi",
"base64 0.21.7", "base64 0.22.1",
"bitflags 2.11.1", "bitflags 2.11.1",
"byteorder", "byteorder",
"bytes", "bytes",
@ -3655,19 +3557,19 @@ dependencies = [
"smallvec", "smallvec",
"sqlx-core", "sqlx-core",
"stringprep", "stringprep",
"thiserror 1.0.69", "thiserror",
"tracing", "tracing",
"whoami", "whoami",
] ]
[[package]] [[package]]
name = "sqlx-postgres" name = "sqlx-postgres"
version = "0.7.4" version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c824eb80b894f926f89a0b9da0c7f435d27cdd35b8c655b114e58223918577e" checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46"
dependencies = [ dependencies = [
"atoi", "atoi",
"base64 0.21.7", "base64 0.22.1",
"bitflags 2.11.1", "bitflags 2.11.1",
"byteorder", "byteorder",
"crc", "crc",
@ -3675,7 +3577,6 @@ dependencies = [
"etcetera", "etcetera",
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-io",
"futures-util", "futures-util",
"hex", "hex",
"hkdf", "hkdf",
@ -3693,16 +3594,16 @@ dependencies = [
"smallvec", "smallvec",
"sqlx-core", "sqlx-core",
"stringprep", "stringprep",
"thiserror 1.0.69", "thiserror",
"tracing", "tracing",
"whoami", "whoami",
] ]
[[package]] [[package]]
name = "sqlx-sqlite" name = "sqlx-sqlite"
version = "0.7.4" version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b244ef0a8414da0bed4bb1910426e890b19e5e9bccc27ada6b797d05c55ae0aa" checksum = "c2d12fe70b2c1b4401038055f90f151b78208de1f9f89a7dbfd41587a10c3eea"
dependencies = [ dependencies = [
"atoi", "atoi",
"flume", "flume",
@ -3715,10 +3616,11 @@ dependencies = [
"log", "log",
"percent-encoding", "percent-encoding",
"serde", "serde",
"serde_urlencoded",
"sqlx-core", "sqlx-core",
"thiserror",
"tracing", "tracing",
"url", "url",
"urlencoding",
] ]
[[package]] [[package]]
@ -3777,17 +3679,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a" checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.117" version = "2.0.117"
@ -3807,7 +3698,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -3833,33 +3724,13 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "thiserror"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [
"thiserror-impl 1.0.69",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "2.0.18" version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
dependencies = [ dependencies = [
"thiserror-impl 2.0.18", "thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.117",
] ]
[[package]] [[package]]
@ -3870,7 +3741,7 @@ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -4032,7 +3903,7 @@ checksum = "050686193eb999b4bb3bc2acfa891a13da00f79734704c4b8b4ef1a10b368a3c"
dependencies = [ dependencies = [
"crossbeam-channel", "crossbeam-channel",
"symlink", "symlink",
"thiserror 2.0.18", "thiserror",
"time", "time",
"tracing-subscriber", "tracing-subscriber",
] ]
@ -4045,7 +3916,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -4154,7 +4025,7 @@ checksum = "a1249a628de3ad34b821ecb1001355bca3940bcb2f88558f1a8bd82e977f75b5"
dependencies = [ dependencies = [
"proc-macro-hack", "proc-macro-hack",
"quote", "quote",
"syn 2.0.117", "syn",
"unic-langid-impl", "unic-langid-impl",
] ]
@ -4203,12 +4074,6 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]]
name = "unicode_categories"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
[[package]] [[package]]
name = "universal-hash" name = "universal-hash"
version = "0.5.1" version = "0.5.1"
@ -4231,12 +4096,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "urlencoding"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
[[package]] [[package]]
name = "utf8_iter" name = "utf8_iter"
version = "1.0.4" version = "1.0.4"
@ -4378,7 +4237,7 @@ dependencies = [
"bumpalo", "bumpalo",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -4487,7 +4346,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -4498,7 +4357,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -4718,7 +4577,7 @@ dependencies = [
"heck 0.5.0", "heck 0.5.0",
"indexmap", "indexmap",
"prettyplease", "prettyplease",
"syn 2.0.117", "syn",
"wasm-metadata", "wasm-metadata",
"wit-bindgen-core", "wit-bindgen-core",
"wit-component", "wit-component",
@ -4734,7 +4593,7 @@ dependencies = [
"prettyplease", "prettyplease",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
"wit-bindgen-core", "wit-bindgen-core",
"wit-bindgen-rust", "wit-bindgen-rust",
] ]
@ -4782,6 +4641,12 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4"
[[package]]
name = "yansi"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
[[package]] [[package]]
name = "yoke" name = "yoke"
version = "0.8.2" version = "0.8.2"
@ -4801,7 +4666,7 @@ checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
"synstructure", "synstructure",
] ]
@ -4822,7 +4687,7 @@ checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]
@ -4842,7 +4707,7 @@ checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
"synstructure", "synstructure",
] ]
@ -4883,7 +4748,7 @@ checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.117", "syn",
] ]
[[package]] [[package]]

View file

@ -28,9 +28,9 @@ futures = "0.3"
url = "2.5" url = "2.5"
[dependencies.sea-orm] [dependencies.sea-orm]
version = "~1.0" version = "1.1"
features = ["debug-print", "macros", "runtime-async-std-native-tls"] features = ["debug-print", "macros", "runtime-async-std-native-tls"]
default-features = false default-features = false
[dependencies.sea-schema] [dependencies.sea-schema]
version = "~0.15" version = "0.16"

View file

@ -42,7 +42,7 @@ Para MySQL o PostgreSQL añade también `db_user`, `db_pass`, `db_host` y `db_po
**Declara la extensión** en tu aplicación o en la extensión que la requiera: **Declara la extensión** en tu aplicación o en la extensión que la requiera:
```rust,no_run ```rust,ignore
use pagetop::prelude::*; use pagetop::prelude::*;
struct MyApp; struct MyApp;
@ -70,7 +70,6 @@ async fn main() -> std::io::Result<()> {
```rust,no_run ```rust,no_run
use pagetop_seaorm::db::*; use pagetop_seaorm::db::*;
#[derive(DeriveMigrationName)]
pub struct Migration; pub struct Migration;
#[async_trait::async_trait] #[async_trait::async_trait]
@ -111,27 +110,22 @@ Este *crate* se apoya en bibliotecas del ecosistema [SeaQL](https://github.com/S
usada por el módulo de migraciones para interrogar la estructura real de la base de datos (tablas, usada por el módulo de migraciones para interrogar la estructura real de la base de datos (tablas,
columnas, índices y claves externas). columnas, índices y claves externas).
También incorpora código adaptado de las siguientes fuentes: El módulo de migraciones (`src/db/migration/`) incorpora una adaptación de
[sea-orm-migration](https://crates.io/crates/sea-orm-migration). El código que se integra procede de
la versión [**1.1.20**](https://github.com/SeaQL/sea-orm/tree/1.1.20/sea-orm-migration) en lugar de
usarlo como dependencia ya que su paradigma de CLI no es compatible con el ciclo de vida de las
extensiones de PageTop, donde las migraciones deben ejecutarse durante la inicialización de cada
extensión. Los ficheros adaptados del original son:
* [**sea-orm-migration (v1.0.0)**](https://github.com/SeaQL/sea-orm/tree/1.0.0/sea-orm-migration): | Archivos | Observaciones |
El módulo de migraciones (`src/db/migration/`) es una versión personalizada de |----------------------------|--------------------------------------------------------------|
[sea-orm-migration](https://crates.io/crates/sea-orm-migration). Se integra directamente en lugar | `lib.rs` en `migration.rs` | Excluye módulos y exportaciones del CLI |
de usarlo como dependencia porque su paradigma de CLI no es compatible con el ciclo de vida de las | `connection.rs` | Integración completa |
extensiones de PageTop, donde las migraciones deben ejecutarse durante la inicialización de cada | `manager.rs` | Adapta *features* propias |
extensión. Los ficheros adaptados del original son: | `migrator.rs` | Adapta *features* propias y omite gestión de errores del CLI |
| `prelude.rs` | Excluye exportaciones del CLI |
| Original en `sea-orm-migration` | Observaciones | | `schema.rs` | Integración ajustada con cambios menores |
|---------------------------------|-----------------------------------------| | `seaql_migrations.rs` | Integración completa |
| `lib.rs` | Excluye módulos y exportaciones del CLI |
| `connection.rs` | Integración completa |
| `manager.rs` | Integración completa |
| `migrator.rs` | Omite la gestión de errores del CLI |
| `prelude.rs` | Excluye exportaciones del CLI |
| `seaql_migrations.rs` | Integración completa |
* [**loco-rs/loco**](https://github.com/loco-rs/loco/blob/master/src/schema.rs): El módulo
`src/db/migration/schema.rs`, con funciones de ayuda para definir columnas de tablas de forma
ergonómica, está adaptado del fichero `src/schema.rs` del proyecto [Loco](https://loco.rs/).
## 🚧 Advertencia ## 🚧 Advertencia

View file

@ -11,17 +11,7 @@ use sea_orm::{ConnectionTrait, DatabaseBackend, Statement};
mod dbconn; mod dbconn;
pub(crate) use dbconn::{run_now, DBCONN}; pub(crate) use dbconn::{run_now, DBCONN};
// The migration module is a customized version of the sea_orm_migration module (v1.0.0) // Adaptación de `sea-orm-migration` (ver §Créditos en README.md).
// https://github.com/SeaQL/sea-orm/tree/1.0.0/sea-orm-migration to avoid errors caused by the
// package paradigm of PageTop. Files integrated from original:
//
// lib.rs => db/migration.rs . . . . . . . . . . . . . . (excluding some modules and exports)
// connection.rs => db/migration/connection.rs . . . . . . . . . . . . . . (full integration)
// manager.rs => db/migration/manager.rs . . . . . . . . . . . . . . . . . (full integration)
// migrator.rs => db/migration/migrator.rs . . . . . . . . . . . .(omitting error management)
// prelude.rs => db/migration/prelude.rs . . . . . . . . . . . . . . . . . . . (avoiding CLI)
// seaql_migrations.rs => db/migration/seaql_migrations.rs . . . . . . . . (full integration)
//
mod migration; mod migration;
pub use migration::prelude::*; pub use migration::prelude::*;
pub use migration::schema::*; pub use migration::schema::*;

View file

@ -11,7 +11,7 @@ pub enum SchemaManagerConnection<'c> {
} }
#[async_trait::async_trait] #[async_trait::async_trait]
impl<'c> ConnectionTrait for SchemaManagerConnection<'c> { impl ConnectionTrait for SchemaManagerConnection<'_> {
fn get_database_backend(&self) -> DbBackend { fn get_database_backend(&self) -> DbBackend {
match self { match self {
SchemaManagerConnection::Connection(conn) => conn.get_database_backend(), SchemaManagerConnection::Connection(conn) => conn.get_database_backend(),
@ -56,7 +56,7 @@ impl<'c> ConnectionTrait for SchemaManagerConnection<'c> {
} }
#[async_trait::async_trait] #[async_trait::async_trait]
impl<'c> TransactionTrait for SchemaManagerConnection<'c> { impl TransactionTrait for SchemaManagerConnection<'_> {
async fn begin(&self) -> Result<DatabaseTransaction, DbErr> { async fn begin(&self) -> Result<DatabaseTransaction, DbErr> {
match self { match self {
SchemaManagerConnection::Connection(conn) => conn.begin().await, SchemaManagerConnection::Connection(conn) => conn.begin().await,
@ -86,7 +86,7 @@ impl<'c> TransactionTrait for SchemaManagerConnection<'c> {
) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'a>> ) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'a>>
+ Send, + Send,
T: Send, T: Send,
E: std::error::Error + Send, E: std::fmt::Display + std::fmt::Debug + Send,
{ {
match self { match self {
SchemaManagerConnection::Connection(conn) => conn.transaction(callback).await, SchemaManagerConnection::Connection(conn) => conn.transaction(callback).await,
@ -106,7 +106,7 @@ impl<'c> TransactionTrait for SchemaManagerConnection<'c> {
) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'a>> ) -> Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'a>>
+ Send, + Send,
T: Send, T: Send,
E: std::error::Error + Send, E: std::fmt::Display + std::fmt::Debug + Send,
{ {
match self { match self {
SchemaManagerConnection::Connection(conn) => { SchemaManagerConnection::Connection(conn) => {

View file

@ -2,11 +2,12 @@ use super::{IntoSchemaManagerConnection, SchemaManagerConnection};
use sea_orm::sea_query::{ use sea_orm::sea_query::{
extension::postgres::{TypeAlterStatement, TypeCreateStatement, TypeDropStatement}, extension::postgres::{TypeAlterStatement, TypeCreateStatement, TypeDropStatement},
ForeignKeyCreateStatement, ForeignKeyDropStatement, IndexCreateStatement, IndexDropStatement, ForeignKeyCreateStatement, ForeignKeyDropStatement, IndexCreateStatement, IndexDropStatement,
TableAlterStatement, TableCreateStatement, TableDropStatement, TableRenameStatement, SelectStatement, TableAlterStatement, TableCreateStatement, TableDropStatement,
TableTruncateStatement, TableRenameStatement, TableTruncateStatement,
}; };
use sea_orm::{ConnectionTrait, DbBackend, DbErr, StatementBuilder}; use sea_orm::{ConnectionTrait, DbBackend, DbErr, StatementBuilder};
use sea_schema::{mysql::MySql, postgres::Postgres, probe::SchemaProbe, sqlite::Sqlite}; #[allow(unused_imports)]
use sea_schema::probe::SchemaProbe;
/// Helper struct for writing migration scripts in migration file /// Helper struct for writing migration scripts in migration file
pub struct SchemaManager<'c> { pub struct SchemaManager<'c> {
@ -41,7 +42,7 @@ impl<'c> SchemaManager<'c> {
} }
/// Schema Creation /// Schema Creation
impl<'c> SchemaManager<'c> { impl SchemaManager<'_> {
pub async fn create_table(&self, stmt: TableCreateStatement) -> Result<(), DbErr> { pub async fn create_table(&self, stmt: TableCreateStatement) -> Result<(), DbErr> {
self.exec_stmt(stmt).await self.exec_stmt(stmt).await
} }
@ -60,7 +61,7 @@ impl<'c> SchemaManager<'c> {
} }
/// Schema Mutation /// Schema Mutation
impl<'c> SchemaManager<'c> { impl SchemaManager<'_> {
pub async fn alter_table(&self, stmt: TableAlterStatement) -> Result<(), DbErr> { pub async fn alter_table(&self, stmt: TableAlterStatement) -> Result<(), DbErr> {
self.exec_stmt(stmt).await self.exec_stmt(stmt).await
} }
@ -95,7 +96,7 @@ impl<'c> SchemaManager<'c> {
} }
/// Schema Inspection. /// Schema Inspection.
impl<'c> SchemaManager<'c> { impl SchemaManager<'_> {
pub async fn has_table<T>(&self, table: T) -> Result<bool, DbErr> pub async fn has_table<T>(&self, table: T) -> Result<bool, DbErr>
where where
T: AsRef<str>, T: AsRef<str>,
@ -103,42 +104,54 @@ impl<'c> SchemaManager<'c> {
has_table(&self.conn, table).await has_table(&self.conn, table).await
} }
pub async fn has_column<T, C>(&self, table: T, column: C) -> Result<bool, DbErr> pub async fn has_column<T, C>(&self, _table: T, _column: C) -> Result<bool, DbErr>
where where
T: AsRef<str>, T: AsRef<str>,
C: AsRef<str>, C: AsRef<str>,
{ {
let stmt = match self.conn.get_database_backend() { let _stmt: SelectStatement = match self.conn.get_database_backend() {
DbBackend::MySql => MySql.has_column(table, column), #[cfg(feature = "mysql")]
DbBackend::Postgres => Postgres.has_column(table, column), DbBackend::MySql => sea_schema::mysql::MySql.has_column(_table, _column),
DbBackend::Sqlite => Sqlite.has_column(table, column), #[cfg(feature = "postgres")]
DbBackend::Postgres => sea_schema::postgres::Postgres.has_column(_table, _column),
#[cfg(feature = "sqlite")]
DbBackend::Sqlite => sea_schema::sqlite::Sqlite.has_column(_table, _column),
#[allow(unreachable_patterns)]
other => panic!("{other:?} feature is off"),
}; };
#[allow(unreachable_code)]
let builder = self.conn.get_database_backend(); let builder = self.conn.get_database_backend();
let res = self let res = self
.conn .conn
.query_one(builder.build(&stmt)) .query_one(builder.build(&_stmt))
.await? .await?
.ok_or_else(|| DbErr::Custom("Failed to check column exists".to_owned()))?; .ok_or_else(|| DbErr::Custom("Failed to check column exists".to_owned()))?;
res.try_get("", "has_column") res.try_get("", "has_column")
} }
pub async fn has_index<T, I>(&self, table: T, index: I) -> Result<bool, DbErr> pub async fn has_index<T, I>(&self, _table: T, _index: I) -> Result<bool, DbErr>
where where
T: AsRef<str>, T: AsRef<str>,
I: AsRef<str>, I: AsRef<str>,
{ {
let stmt = match self.conn.get_database_backend() { let _stmt: SelectStatement = match self.conn.get_database_backend() {
DbBackend::MySql => MySql.has_index(table, index), #[cfg(feature = "mysql")]
DbBackend::Postgres => Postgres.has_index(table, index), DbBackend::MySql => sea_schema::mysql::MySql.has_index(_table, _index),
DbBackend::Sqlite => Sqlite.has_index(table, index), #[cfg(feature = "postgres")]
DbBackend::Postgres => sea_schema::postgres::Postgres.has_index(_table, _index),
#[cfg(feature = "sqlite")]
DbBackend::Sqlite => sea_schema::sqlite::Sqlite.has_index(_table, _index),
#[allow(unreachable_patterns)]
other => panic!("{other:?} feature is off"),
}; };
#[allow(unreachable_code)]
let builder = self.conn.get_database_backend(); let builder = self.conn.get_database_backend();
let res = self let res = self
.conn .conn
.query_one(builder.build(&stmt)) .query_one(builder.build(&_stmt))
.await? .await?
.ok_or_else(|| DbErr::Custom("Failed to check index exists".to_owned()))?; .ok_or_else(|| DbErr::Custom("Failed to check index exists".to_owned()))?;
@ -146,20 +159,26 @@ impl<'c> SchemaManager<'c> {
} }
} }
pub(crate) async fn has_table<C, T>(conn: &C, table: T) -> Result<bool, DbErr> pub(crate) async fn has_table<C, T>(conn: &C, _table: T) -> Result<bool, DbErr>
where where
C: ConnectionTrait, C: ConnectionTrait,
T: AsRef<str>, T: AsRef<str>,
{ {
let stmt = match conn.get_database_backend() { let _stmt: SelectStatement = match conn.get_database_backend() {
DbBackend::MySql => MySql.has_table(table), #[cfg(feature = "mysql")]
DbBackend::Postgres => Postgres.has_table(table), DbBackend::MySql => sea_schema::mysql::MySql.has_table(_table),
DbBackend::Sqlite => Sqlite.has_table(table), #[cfg(feature = "postgres")]
DbBackend::Postgres => sea_schema::postgres::Postgres.has_table(_table),
#[cfg(feature = "sqlite")]
DbBackend::Sqlite => sea_schema::sqlite::Sqlite.has_table(_table),
#[allow(unreachable_patterns)]
other => panic!("{other:?} feature is off"),
}; };
#[allow(unreachable_code)]
let builder = conn.get_database_backend(); let builder = conn.get_database_backend();
let res = conn let res = conn
.query_one(builder.build(&stmt)) .query_one(builder.build(&_stmt))
.await? .await?
.ok_or_else(|| DbErr::Custom("Failed to check table exists".to_owned()))?; .ok_or_else(|| DbErr::Custom("Failed to check table exists".to_owned()))?;

View file

@ -7,7 +7,7 @@ use std::time::SystemTime;
use pagetop::trace::info; use pagetop::trace::info;
use sea_orm::sea_query::{ use sea_orm::sea_query::{
self, extension::postgres::Type, Alias, Expr, ForeignKey, IntoIden, JoinType, Order, Query, self, extension::postgres::Type, Alias, Expr, ExprTrait, ForeignKey, IntoIden, Order, Query,
SelectStatement, SimpleExpr, Table, SelectStatement, SimpleExpr, Table,
}; };
use sea_orm::{ use sea_orm::{
@ -15,7 +15,8 @@ use sea_orm::{
DynIden, EntityTrait, FromQueryResult, Iterable, QueryFilter, Schema, Statement, DynIden, EntityTrait, FromQueryResult, Iterable, QueryFilter, Schema, Statement,
TransactionTrait, TransactionTrait,
}; };
use sea_schema::{mysql::MySql, postgres::Postgres, probe::SchemaProbe, sqlite::Sqlite}; #[allow(unused_imports)]
use sea_schema::probe::SchemaProbe;
use super::{seaql_migrations, IntoSchemaManagerConnection, MigrationTrait, SchemaManager}; use super::{seaql_migrations, IntoSchemaManagerConnection, MigrationTrait, SchemaManager};
@ -445,9 +446,14 @@ where
C: ConnectionTrait, C: ConnectionTrait,
{ {
match db.get_database_backend() { match db.get_database_backend() {
DbBackend::MySql => MySql.query_tables(), #[cfg(feature = "mysql")]
DbBackend::Postgres => Postgres.query_tables(), DbBackend::MySql => sea_schema::mysql::MySql.query_tables(),
DbBackend::Sqlite => Sqlite.query_tables(), #[cfg(feature = "postgres")]
DbBackend::Postgres => sea_schema::postgres::Postgres.query_tables(),
#[cfg(feature = "sqlite")]
DbBackend::Sqlite => sea_schema::sqlite::Sqlite.query_tables(),
#[allow(unreachable_patterns)]
other => panic!("{other:?} feature is off"),
} }
} }
@ -456,9 +462,14 @@ where
C: ConnectionTrait, C: ConnectionTrait,
{ {
match db.get_database_backend() { match db.get_database_backend() {
DbBackend::MySql => MySql::get_current_schema(), #[cfg(feature = "mysql")]
DbBackend::Postgres => Postgres::get_current_schema(), DbBackend::MySql => sea_schema::mysql::MySql::get_current_schema(),
DbBackend::Sqlite => unimplemented!(), #[cfg(feature = "postgres")]
DbBackend::Postgres => sea_schema::postgres::Postgres::get_current_schema(),
#[cfg(feature = "sqlite")]
DbBackend::Sqlite => sea_schema::sqlite::Sqlite::get_current_schema(),
#[allow(unreachable_patterns)]
other => panic!("{other:?} feature is off"),
} }
} }
@ -490,7 +501,7 @@ where
)) ))
.cond_where( .cond_where(
Condition::all() Condition::all()
.add(Expr::expr(get_current_schema(db)).equals(( .add(get_current_schema(db).equals((
InformationSchema::TableConstraints, InformationSchema::TableConstraints,
InformationSchema::TableSchema, InformationSchema::TableSchema,
))) )))
@ -508,11 +519,20 @@ where
#[derive(DeriveIden)] #[derive(DeriveIden)]
enum PgType { enum PgType {
Table, Table,
Oid,
Typname, Typname,
Typnamespace, Typnamespace,
Typelem, Typelem,
} }
#[derive(DeriveIden)]
enum PgDepend {
Table,
Objid,
Deptype,
Refclassid,
}
#[derive(DeriveIden)] #[derive(DeriveIden)]
enum PgNamespace { enum PgNamespace {
Table, Table,
@ -524,24 +544,28 @@ fn query_pg_types<C>(db: &C) -> SelectStatement
where where
C: ConnectionTrait, C: ConnectionTrait,
{ {
let mut stmt = Query::select(); Query::select()
stmt.column(PgType::Typname) .column(PgType::Typname)
.from(PgType::Table) .from(PgType::Table)
.join( .left_join(
JoinType::LeftJoin,
PgNamespace::Table, PgNamespace::Table,
Expr::col((PgNamespace::Table, PgNamespace::Oid)) Expr::col((PgNamespace::Table, PgNamespace::Oid))
.equals((PgType::Table, PgType::Typnamespace)), .equals((PgType::Table, PgType::Typnamespace)),
) )
.cond_where( .left_join(
Condition::all() PgDepend::Table,
.add( Expr::col((PgDepend::Table, PgDepend::Objid))
Expr::expr(get_current_schema(db)) .equals((PgType::Table, PgType::Oid))
.equals((PgNamespace::Table, PgNamespace::Nspname)), .and(
Expr::col((PgDepend::Table, PgDepend::Refclassid))
.eq(Expr::cust("'pg_extension'::regclass::oid")),
) )
.add(Expr::col((PgType::Table, PgType::Typelem)).eq(0)), .and(Expr::col((PgDepend::Table, PgDepend::Deptype)).eq(Expr::cust("'e'"))),
); )
stmt .and_where(get_current_schema(db).equals((PgNamespace::Table, PgNamespace::Nspname)))
.and_where(Expr::col((PgType::Table, PgType::Typelem)).eq(0))
.and_where(Expr::col((PgDepend::Table, PgDepend::Objid)).is_null())
.take()
} }
trait QueryTable { trait QueryTable {

View file

@ -10,4 +10,3 @@ pub use sea_orm;
pub use sea_orm::sea_query; pub use sea_orm::sea_query;
pub use sea_orm::sea_query::*; pub use sea_orm::sea_query::*;
pub use sea_orm::DeriveIden; pub use sea_orm::DeriveIden;
pub use sea_orm::DeriveMigrationName;

View file

@ -73,6 +73,11 @@ pub fn pk_auto<T: IntoIden>(name: T) -> ColumnDef {
integer(name).auto_increment().primary_key().take() integer(name).auto_increment().primary_key().take()
} }
/// Create a UUID primary key
pub fn pk_uuid<T: IntoIden>(name: T) -> ColumnDef {
uuid(name).primary_key().take()
}
pub fn char_len<T: IntoIden>(col: T, length: u32) -> ColumnDef { pub fn char_len<T: IntoIden>(col: T, length: u32) -> ColumnDef {
ColumnDef::new(col).char_len(length).not_null().take() ColumnDef::new(col).char_len(length).not_null().take()
} }
@ -538,11 +543,11 @@ pub fn uuid_uniq<T: IntoIden>(col: T) -> ColumnDef {
uuid(col).unique_key().take() uuid(col).unique_key().take()
} }
pub fn custom<T: IntoIden>(col: T, name: T) -> ColumnDef { pub fn custom<T: IntoIden, N: IntoIden>(col: T, name: N) -> ColumnDef {
ColumnDef::new(col).custom(name).not_null().take() ColumnDef::new(col).custom(name).not_null().take()
} }
pub fn custom_null<T: IntoIden>(col: T, name: T) -> ColumnDef { pub fn custom_null<T: IntoIden, N: IntoIden>(col: T, name: N) -> ColumnDef {
ColumnDef::new(col).custom(name).null().take() ColumnDef::new(col).custom(name).null().take()
} }