-
Notifications
You must be signed in to change notification settings - Fork 457
Closed
Labels
Description
Problem
When setting up the sql plugin, the ‘preload’ parameter is only used for migrations and assumes that the migration is given
plugins-workspace/plugins/sql/src/lib.rs
Lines 145 to 153 in 7e1c17a
| for db in config.preload { | |
| let pool = DbPool::connect(&db, app).await?; | |
| if let Some(migrations) = self.migrations.as_mut().unwrap().remove(&db) { | |
| let migrator = Migrator::new(migrations).await?; | |
| pool.migrate(&migrator).await?; | |
| } | |
| lock.insert(db, pool); |
This does not seem to match its semantics.
If I use the SQL plugin and give a preload parameter but don't provide any migrations, the programme reports the following panic message

This is very unintuitive, and although preload is currently only used by migration, it would be better to report an error like no migration providing.
Improvements
I have the following ideas to fix the current problem
- rename
preloadto something else related tomigration, such asmigration-preload. preloadis not only used for migrations, but also for opening connections and managing them- provide a more user friendly panic message