diff --git a/pagetop-node/Cargo.toml b/pagetop-node/Cargo.toml index 71412013..b2fa9fec 100644 --- a/pagetop-node/Cargo.toml +++ b/pagetop-node/Cargo.toml @@ -13,5 +13,7 @@ homepage = "https://suitepro.cillero.es/projects/pagetop" repository = "https://gitlab.com/manuelcillero/pagetop" license = "Apache-2.0 or MIT" -[dependencies] -pagetop = { path = "../pagetop" } +[dependencies.pagetop] +path = "../pagetop" +features = ["database"] +default-features = false diff --git a/pagetop-user/Cargo.toml b/pagetop-user/Cargo.toml index 8781d7ff..01c28e4b 100644 --- a/pagetop-user/Cargo.toml +++ b/pagetop-user/Cargo.toml @@ -13,6 +13,10 @@ homepage = "https://suitepro.cillero.es/projects/pagetop" repository = "https://gitlab.com/manuelcillero/pagetop" license = "Apache-2.0 or MIT" +[dependencies.pagetop] +path = "../pagetop" +features = ["database"] +default-features = false + [dependencies] -pagetop = { path = "../pagetop" } serde = { version = "1.0", features = ["derive"] } diff --git a/pagetop/Cargo.toml b/pagetop/Cargo.toml index 9d6034ca..ad3604d4 100644 --- a/pagetop/Cargo.toml +++ b/pagetop/Cargo.toml @@ -64,9 +64,10 @@ optional = true [features] default = [] -mysql = ["sea-orm", "sea-orm-migration", "sea-orm/sqlx-mysql"] -postgres = ["sea-orm", "sea-orm-migration", "sea-orm/sqlx-postgres"] -sqlite = ["sea-orm", "sea-orm-migration", "sea-orm/sqlx-sqlite"] +database = ["sea-orm", "sea-orm-migration"] +mysql = ["database", "sea-orm/sqlx-mysql"] +postgres = ["database", "sea-orm/sqlx-postgres"] +sqlite = ["database", "sea-orm/sqlx-sqlite"] [build-dependencies] static-files = "0.2.3" diff --git a/pagetop/STARTER.bin.Cargo.toml b/pagetop/STARTER.bin.Cargo.toml index 4958aea5..f5d375c4 100644 --- a/pagetop/STARTER.bin.Cargo.toml +++ b/pagetop/STARTER.bin.Cargo.toml @@ -8,13 +8,11 @@ edition = "2021" [dependencies.pagetop] path = "../pagetop" -# Si se usa base de datos: +# Si requiere base de datos (MySql, Postgres y/o SQLite): features = ["mysql"] # features = ["postgres"] # features = ["sqlite"] -# Soporte alternativo a todas las bases de datos: -# features = ["mysql", "postgres", "sqlite"] -# En estos casos hay que deshabilitar las características predeterminadas: +# En este caso hay que deshabilitar las características predeterminadas: default-features = false [dependencies] diff --git a/pagetop/STARTER.lib.Cargo.toml b/pagetop/STARTER.lib.Cargo.toml index 7c06a7fd..0cdc858a 100644 --- a/pagetop/STARTER.lib.Cargo.toml +++ b/pagetop/STARTER.lib.Cargo.toml @@ -6,8 +6,14 @@ edition = "2021" # Ver más claves y sus definiciones en # https://doc.rust-lang.org/cargo/reference/manifest.html +[dependencies.pagetop] +path = "../pagetop" +# Para dar soporte a bases de datos: +features = ["database"] +# En este caso hay que deshabilitar las características predeterminadas: +default-features = false + [dependencies] -pagetop = { path = "../pagetop" } # Si se usa la macro html!: maud = { git = "https://github.com/lambda-fairy/maud", rev = "e6787cd6" } # Si se requiere serialización de estructuras de datos: diff --git a/pagetop/src/app.rs b/pagetop/src/app.rs index 80237c40..0ff72856 100644 --- a/pagetop/src/app.rs +++ b/pagetop/src/app.rs @@ -8,7 +8,7 @@ mod tracing; pub mod locale; -#[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] +#[cfg(feature = "database")] pub mod db; mod definition; diff --git a/pagetop/src/app/application.rs b/pagetop/src/app/application.rs index aa49adcb..e68a0b95 100644 --- a/pagetop/src/app/application.rs +++ b/pagetop/src/app/application.rs @@ -24,7 +24,7 @@ impl Application { LazyStatic::force(&super::locale::LANGID); // Conecta con la base de datos (opcional). - #[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] + #[cfg(feature = "database")] LazyStatic::force(&super::db::DBCONN); // Habilita los módulos predeterminados. @@ -46,7 +46,7 @@ impl Application { module::all::register_actions(); // Ejecuta actualizaciones pendientes de la base de datos (opcional). - #[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] + #[cfg(feature = "database")] module::all::run_migrations(); // Ejecuta la función de inicio de la aplicación. diff --git a/pagetop/src/core/module/all.rs b/pagetop/src/core/module/all.rs index 4e6c6282..d0b48655 100644 --- a/pagetop/src/core/module/all.rs +++ b/pagetop/src/core/module/all.rs @@ -2,7 +2,7 @@ use super::ModuleTrait; use crate::core::hook::add_action; use crate::{app, trace, LazyStatic}; -#[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] +#[cfg(feature = "database")] use crate::{db::*, run_now}; use std::sync::RwLock; @@ -66,7 +66,7 @@ pub fn register_actions() { } } -#[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] +#[cfg(feature = "database")] pub fn run_migrations() { run_now({ struct Migrator; diff --git a/pagetop/src/core/module/definition.rs b/pagetop/src/core/module/definition.rs index dbf6904e..59aec809 100644 --- a/pagetop/src/core/module/definition.rs +++ b/pagetop/src/core/module/definition.rs @@ -1,7 +1,7 @@ use crate::core::hook::HookAction; use crate::{app, util}; -#[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] +#[cfg(feature = "database")] use crate::db::MigrationItem; pub trait BaseModule { @@ -31,7 +31,7 @@ pub trait ModuleTrait: BaseModule + Send + Sync { vec![] } - #[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] + #[cfg(feature = "database")] #[allow(unused_variables)] fn migrations(&self) -> Vec { vec![] diff --git a/pagetop/src/lib.rs b/pagetop/src/lib.rs index 5d788104..cfcaf8ad 100644 --- a/pagetop/src/lib.rs +++ b/pagetop/src/lib.rs @@ -21,7 +21,7 @@ pub mod locale; pub mod html; // Acceso a base de datos. -#[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] +#[cfg(feature = "database")] pub mod db; // Prepare and run the application. diff --git a/pagetop/src/prelude.rs b/pagetop/src/prelude.rs index 20fa3e9d..b1c29c63 100644 --- a/pagetop/src/prelude.rs +++ b/pagetop/src/prelude.rs @@ -11,7 +11,7 @@ pub use crate::localize; pub use crate::html::*; -#[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] +#[cfg(feature = "database")] pub use crate::{db, db::*, migration_item, pub_migration}; pub use crate::app;