sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Allow passing `--ignore-missing` to `sqlx::migrate!` macro

Open nipunn1313 opened this issue 3 years ago • 3 comments

The CLI's sqlx migrate run has a --ignore-missing flag which I'd love to be able to pass to the migrate macro. Currently the migrate macro hardcodes ignore_missing: false

Currently it's used as such:

static MIGRATOR: Migrator = sqlx::migrate!();

It is possible to do it like this

static MIGRATOR: Migrator = {
    let mut m = sqlx::migrate!();
    m.ignore_missing = true;
    m
};

Would like something more ergonomic

nipunn1313 avatar Apr 06 '22 18:04 nipunn1313

@nipunn1313 Is this what you're looking for?

static MIGRATOR: Migrator = sqlx::migrate!("")
        .set_ignore_missing(true)

EddieWhi avatar Jul 11 '24 10:07 EddieWhi

yep! That works!

nipunn1313 avatar Jul 11 '24 16:07 nipunn1313

Actually, it does not work.

expected Migrator found &Migrator because set_ignore_missing takes in &mut self and returns self. Would need to be more of a builder pattern.

Or alternately, an argument to migrate.

nipunn1313 avatar Jul 11 '24 16:07 nipunn1313