Change database log level to debug
This commit is contained in:
@@ -14,6 +14,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
tokio = { version = "1.47.0", features = ["full"] }
|
tokio = { version = "1.47.0", features = ["full"] }
|
||||||
sea-orm = { version = "2.0.0-rc", features = [ "sqlx-postgres", "sqlx-mysql", "sqlx-sqlite", "runtime-tokio-rustls", "macros", "mock", "with-chrono", "with-json", "with-uuid", "sqlite-use-returning-for-3_35", "mariadb-use-returning" ] }
|
sea-orm = { version = "2.0.0-rc", features = [ "sqlx-postgres", "sqlx-mysql", "sqlx-sqlite", "runtime-tokio-rustls", "macros", "mock", "with-chrono", "with-json", "with-uuid", "sqlite-use-returning-for-3_35", "mariadb-use-returning" ] }
|
||||||
|
log = "0.4.28"
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use log::LevelFilter;
|
||||||
pub use sea_orm::ConnectOptions;
|
pub use sea_orm::ConnectOptions;
|
||||||
pub mod generated;
|
pub mod generated;
|
||||||
|
|
||||||
@@ -13,7 +14,8 @@ pub async fn get_connection<T: FnOnce(&mut ConnectOptions)>(
|
|||||||
.connect_timeout(std::time::Duration::from_secs(8))
|
.connect_timeout(std::time::Duration::from_secs(8))
|
||||||
.idle_timeout(std::time::Duration::from_secs(8))
|
.idle_timeout(std::time::Duration::from_secs(8))
|
||||||
.test_before_acquire(true)
|
.test_before_acquire(true)
|
||||||
.sqlx_logging(true);
|
.sqlx_logging(true)
|
||||||
|
.sqlx_logging_level(LevelFilter::Debug);
|
||||||
|
|
||||||
if let Some(option_fn) = option_fn {
|
if let Some(option_fn) = option_fn {
|
||||||
option_fn(&mut opt);
|
option_fn(&mut opt);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ path = "src/lib.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1", features = ["macros", "rt", "rt-multi-thread"] }
|
tokio = { version = "1", features = ["macros", "rt", "rt-multi-thread"] }
|
||||||
sea-orm-cli = { version = "2.0.0-rc", features = ["sqlx-postgres", "sqlx-mysql", "sqlx-sqlite", "runtime-tokio"] }
|
sea-orm-cli = { version = "2.0.0-rc", features = ["sqlx-postgres", "sqlx-mysql", "sqlx-sqlite", "runtime-tokio"] }
|
||||||
|
log = "0.4.28"
|
||||||
|
|
||||||
[dependencies.sea-orm-migration]
|
[dependencies.sea-orm-migration]
|
||||||
version = "2.0.0-rc"
|
version = "2.0.0-rc"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ pub use sea_orm_migration::prelude::*;
|
|||||||
|
|
||||||
mod migrations;
|
mod migrations;
|
||||||
use migrations::*;
|
use migrations::*;
|
||||||
use sea_orm_migration::sea_orm::Database;
|
use sea_orm_migration::sea_orm::{ConnectOptions, Database};
|
||||||
|
|
||||||
pub struct Migrator;
|
pub struct Migrator;
|
||||||
|
|
||||||
@@ -17,7 +17,16 @@ impl MigratorTrait for Migrator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn migrate_database(db_url: &str) -> Result<(), DbErr> {
|
pub async fn migrate_database(db_url: &str) -> Result<(), DbErr> {
|
||||||
let db = Database::connect(db_url).await?;
|
let mut opt = ConnectOptions::new(db_url);
|
||||||
|
opt.max_connections(10)
|
||||||
|
.min_connections(0)
|
||||||
|
.connect_timeout(std::time::Duration::from_secs(8))
|
||||||
|
.idle_timeout(std::time::Duration::from_secs(8))
|
||||||
|
.test_before_acquire(true)
|
||||||
|
.sqlx_logging(true)
|
||||||
|
.sqlx_logging_level(log::LevelFilter::Debug);
|
||||||
|
let db = Database::connect(opt).await?;
|
||||||
|
|
||||||
Migrator::up(&db, None).await
|
Migrator::up(&db, None).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user