fix in mysql
This commit is contained in:
+12
-4
@@ -29,10 +29,18 @@ impl Database {
|
||||
sqlx::any::install_default_drivers();
|
||||
let kind = DatabaseKind::from_url(url)?;
|
||||
debug!(?kind, max_connections, "initializing database pool");
|
||||
let pool = AnyPoolOptions::new()
|
||||
.max_connections(max_connections)
|
||||
.connect(url)
|
||||
.await?;
|
||||
let mut options = AnyPoolOptions::new().max_connections(max_connections);
|
||||
if kind == DatabaseKind::MySql {
|
||||
options = options.after_connect(|connection, _metadata| {
|
||||
Box::pin(async move {
|
||||
sqlx::query("SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci")
|
||||
.execute(connection)
|
||||
.await?;
|
||||
Ok(())
|
||||
})
|
||||
});
|
||||
}
|
||||
let pool = options.connect(url).await?;
|
||||
if kind == DatabaseKind::Sqlite {
|
||||
debug!("applying SQLite connection pragmas");
|
||||
sqlx::query(queries::get(kind, queries::SQLITE_FOREIGN_KEYS_ON))
|
||||
|
||||
Reference in New Issue
Block a user