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

Add support for creating unique indexes #442

Merged
merged 7 commits into from
Nov 5, 2024

Conversation

kvch
Copy link
Contributor

@kvch kvch commented Oct 29, 2024

This PR adds a new attribute to create_index operation.
From now on it is possible to create a unique index on one or more
columns in a table.

@kvch kvch mentioned this pull request Oct 29, 2024
@kvch kvch requested a review from andrew-farries October 29, 2024 16:32
@kvch kvch enabled auto-merge (squash) October 30, 2024 09:33
@kvch kvch requested a review from exekias October 30, 2024 10:42
Copy link
Collaborator

@andrew-farries andrew-farries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a few ways of ways to make unique columns now:

  • setting unique: true on a column when it's created: [example]
  • using an alter column operation to set a column as unique: [example]

And now creating unique indexes as of this PR.

I think this is fine. One thing to be aware of is that we don't currently duplicate indexes on a column when duplicating it [see https://github.com//issues/227], so if we have a unique index on a column and and then add, for example, a NOT NULL constraint to that column, the unique index will be lost.

@kvch kvch merged commit ac1dd85 into xataio:main Nov 5, 2024
26 checks passed
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.

2 participants