Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

"NULLS NOT DISTINCT" for indexes in PostgreSQL 15+ #1814

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

Merged
merged 3 commits into from
Jun 10, 2024

Conversation

Domanser
Copy link
Contributor

This pull request adds support of "NULLS NOT DISTINCT" option for PostgreSQL.

By default, unique indexes in PostgreSQL allow multiple null values (so, null values are considered not equal to each other). In PostgreSQL 15, new option was added: "NULLS NOT DISTINCT", which allows only single null value.
https://www.postgresql.org/docs/current/sql-createindex.html

Before PostgreSQL 15, there was a workaround with two indexes: https://stackoverflow.com/questions/8289100/create-unique-constraint-with-null-columns

To enable "NULLS NOT DISTINCT" for index, UniqueNullsNotDistinct method should be called:

Create.Index("MyIndex").OnTable("MyTable1").InSchema("public")
   .OnColumn("Column1").Ascending()
   .OnColumn("Column2").Ascending()
   .WithOptions().UniqueNullsNotDistinct();

Runner should be configured with AddPostgres15_0:

services
   .AddFluentMigratorCore()
   .ConfigureRunner(builder => builder.AddPostgres15_0());

@jzabroski
Copy link
Collaborator

@lillo42 would you like to review this feature?

@lillo42
Copy link
Contributor

lillo42 commented Jun 10, 2024

@jzabroski LGTM

@jzabroski jzabroski merged commit 7fb9d5f into fluentmigrator:main Jun 10, 2024
@jzabroski jzabroski added this to the 6.0.0 milestone Jun 10, 2024
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

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.