(env: Arc<Env>)
| 198 | } |
| 199 | |
| 200 | pub async fn init_db(env: Arc<Env>) -> Result<DatabaseConnection> { |
| 201 | let db = Database::connect_proxy(DbBackend::Sqlite, Arc::new(Box::new(ProxyDb { env }))) |
| 202 | .await |
| 203 | .context("Failed to connect to database")?; |
| 204 | let builder = db.get_database_backend(); |
| 205 | |
| 206 | console_log!("Connected to database"); |
| 207 | |
| 208 | db.execute( |
| 209 | builder.build( |
| 210 | Schema::new(builder) |
| 211 | .create_table_from_entity(crate::entity::Entity) |
| 212 | .if_not_exists(), |
| 213 | ), |
| 214 | ) |
| 215 | .await?; |
| 216 | |
| 217 | Ok(db) |
| 218 | } |
no test coverage detected