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

Request to add a fluent entity existence check to entity creation and deletion statements #1802

Open
TheSquidCombatant opened this issue May 14, 2024 · 1 comment

Comments

@TheSquidCombatant
Copy link

There is a fairly common scenario for applying updates to a database: create an entity if it does not exist, or delete an entity if it exists. Now the code looks like this:

    var exists = Schema
        .Table("Users")
        .Index("IX_Users_CreateDate")
        .Exists();

    if (!exists) Create
        .Index("IX_Users_CreateDate")
        .OnTable("Users")
        .OnColumn("CreateDate").Ascending();

But I would like to write the code like this:

    Create
        .Index("IX_Users_CreateDate")
        .OnTable("Users")
        .OnColumn("CreateDate").Ascending()
        .WithOptions().IfNotExists(); // no boilerplate code anymore

This would allow us not to write boilerplate code and avoid typos when duplicating the spelling of entity names.

@TheSquidCombatant
Copy link
Author

Please check the implementation in this pull request #1801

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant