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

Preconditions #1281

Open
jzabroski opened this issue Jun 18, 2020 · 1 comment
Open

Preconditions #1281

jzabroski opened this issue Jun 18, 2020 · 1 comment
Labels
improvement Improvement of behavior or code quality

Comments

@jzabroski
Copy link
Collaborator

From #664 , @DustinVenegas wrote a good suggestion:

I believe a fluent expression syntax for Preconditions might be useful here instead. That chaining methodology might be less invasive and more flexible in the long-run since it would be easy to extend to arbitrary preconditions. Something to the effect of:

Create.Table("foo")
    .WithPrecondition(Preconditions.MustNotExist)
    .WithIdColumn();

Alter.Table("bar")
    .AddColumn("someCol")
    .Precondition(Preconditions.MustNotExist);

Delete.Table("foo")
    .WithPrecondition(Preconditions.MustExist);

Effectively, Preconditions are like our Conditionals today, except they do not actually connect to the database to determine their truthiness.

Advantages could be:

  1. Possibly improve error logging. If a migration command fails, we can explicitly state any preconditions that should be checked.
  2. It might be possible for FluentMigrator to maintain a MVCC-like data structure of object changes, such that it knows if the precondition is true or not. People could then even "inject" a Database "WORLD STATE" into the Runner, and do a dry run to assert truthiness.
@danpadmore
Copy link

I would love this feature, because currently I rely on preview for generating scripts, but Schema.Exists executes during script generation instead of generating the required script in the preview.

@schambers schambers added the improvement Improvement of behavior or code quality label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement of behavior or code quality
Projects
None yet
Development

No branches or pull requests

3 participants