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 docs for @unique directive in schema #638

Closed
wants to merge 1 commit into from
Closed

Conversation

mangalaman93
Copy link
Contributor

No description provided.

@netlify
Copy link

netlify bot commented Aug 28, 2023

Deploy Preview for dgraph-docs-repo ready!

Name Link
🔨 Latest commit 854083b
🔍 Latest deploy log https://app.netlify.com/sites/dgraph-docs-repo/deploys/64ec99dea86beb000841abeb
😎 Deploy Preview https://deploy-preview-638--dgraph-docs-repo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

mangalaman93 added a commit to dgraph-io/dgraph that referenced this pull request Aug 28, 2023
#8827)

Partially Fixes #8827
Closes: DGRAPHCORE-206
Docs PR: dgraph-io/dgraph-docs#638

This PR adds support for uniqueness constraint using @unique directive
in DQL schema. This unique directive ensures that all values of the
predicate are different in a Dgraph Cluster. This completes phase 1, and
enables adding a new predicate with unique directive. As part of the
phase 2, we will work on adding support for unique directive for
existing predicates.

## Performance
Live Loader before this change on 21 million dataset took 10m54s whereas
after this change took 11m02s. It did not make any significant different
to non-unique predicates.

## How to Use
You can now specify unique in schema as follows: `email: string @unique
@Index(hash) @upsert .`. Now, Dgraph will ensure that no mutation adds a
duplicate for the predicate email.

## Phase 2 [TODO]
- [ ] check if @unique can be added to schema depending upon whether
existing data has any duplicates. If the existing data has any
duplicates, we do not allow adding the @unique directive and return a
query that allows user to identify these UIDs.
- [ ] If index computation is in progress, we should not allow mutations
with predicates for which @unique is set
- [ ] Fix ACL to ensure that we do not end up adding duplicate users
- [ ] Ensure that unique constraint is not violated during Bulk loader

---------

Co-authored-by: Aman Mangal <aman@dgraph.io>
@Rajakavitha1
Copy link
Contributor

Hi @mangalaman93 can we please change the status of this PR to draft

@mangalaman93 mangalaman93 marked this pull request as draft September 5, 2023 04:46
@mangalaman93
Copy link
Contributor Author

closing in lieu of #644

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.

None yet

2 participants