Skip to content

SQL Plugin: The preload parameter has a potential migration requirement. #1930

@Goodjooy

Description

@Goodjooy

Problem

When setting up the sql plugin, the ‘preload’ parameter is only used for migrations and assumes that the migration is given

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
image

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

  1. rename preload to something else related to migration, such as migration-preload.
  2. preload is not only used for migrations, but also for opening connections and managing them
  3. provide a more user friendly panic message

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions