refactor(sql): ignore migration miss

pull/1932/head
FrozenString 10 months ago
parent 002b7a252e
commit 14892747ec

@ -168,7 +168,6 @@ fn main() {
To apply the migrations when the plugin is initialized, add the connection string to the `tauri.conf.json` file:
> Notice: If `migration` is not provided, make sure that `preload` is kept empty
```json
{

@ -145,14 +145,11 @@ impl Builder {
for db in config.preload {
let pool = DbPool::connect(&db, app).await?;
if let Some(migration_map) = self.migrations.as_mut(){
if let Some(migrations)= migration_map.remove(&db){
let migrator = Migrator::new(migrations).await?;
pool.migrate(&migrator).await?;
}
}
else{
panic!("No migrations providing. Please provide at least one migration or clear `preload` list");
if let Some(migrations) =
self.migrations.as_mut().and_then(|mm| mm.remove(&db))
{
let migrator = Migrator::new(migrations).await?;
pool.migrate(&migrator).await?;
}
lock.insert(db, pool);

Loading…
Cancel
Save