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: 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 ```json
{ {

@ -145,14 +145,11 @@ impl Builder {
for db in config.preload { for db in config.preload {
let pool = DbPool::connect(&db, app).await?; let pool = DbPool::connect(&db, app).await?;
if let Some(migration_map) = self.migrations.as_mut(){ if let Some(migrations) =
if let Some(migrations)= migration_map.remove(&db){ self.migrations.as_mut().and_then(|mm| mm.remove(&db))
let migrator = Migrator::new(migrations).await?; {
pool.migrate(&migrator).await?; 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");
} }
lock.insert(db, pool); lock.insert(db, pool);

Loading…
Cancel
Save