Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing --ignore-missing to sqlx::migrate! macro #1788

Open
nipunn1313 opened this issue Apr 6, 2022 · 3 comments · May be fixed by #3526
Open

Allow passing --ignore-missing to sqlx::migrate! macro #1788

nipunn1313 opened this issue Apr 6, 2022 · 3 comments · May be fixed by #3526
Labels
migrations Proposals or bugs involving migrations

Comments

@nipunn1313
Copy link

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

@abonander abonander added the migrations Proposals or bugs involving migrations label Apr 7, 2022
@EddieWhi
Copy link

@nipunn1313
Is this what you're looking for?

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

@nipunn1313
Copy link
Author

yep! That works!

@nipunn1313
Copy link
Author

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 nipunn1313 linked a pull request Oct 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migrations Proposals or bugs involving migrations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants