sqlx
sqlx copied to clipboard
Allow passing `--ignore-missing` to `sqlx::migrate!` macro
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 Is this what you're looking for?
static MIGRATOR: Migrator = sqlx::migrate!("")
.set_ignore_missing(true)
yep! That works!
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.