-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Enforce unique constraints for 0.33 #8645
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR implements unique constraint enforcement and reorganizes upgrade commands for version 0.33. Here's a concise summary of the key changes:
- Moved 0.33 upgrade commands out of 0.32 directory into dedicated 0.33 folder for better organization
- Added unique constraint enforcement for company domain names and person email addresses
- Implemented flexible command flags for controlling unique constraint enforcement (--person, --company, --view-field, --view-sort)
- Added verbose logging option (--verbose) for detailed constraint enforcement tracking
- Enhanced error handling to continue processing remaining workspaces if one fails during upgrade
The changes appear well-structured and maintain data integrity during the upgrade process.
9 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
await this.enforceUniqueConstraintsCommand.executeActiveWorkspacesCommand( | ||
passedParam, | ||
{ | ||
...options, | ||
company: true, | ||
person: true, | ||
viewField: false, | ||
viewSort: false, | ||
}, | ||
workspaceIds, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Consider error handling here - if unique constraint enforcement fails, workspace metadata sync and search vector updates may be in an inconsistent state
@WorkspaceIsUnique() | ||
*/ | ||
[DOMAIN_NAME_FIELD_NAME]?: LinksMetadata; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Enabling unique constraint on domainName could cause issues with existing duplicate data. Make sure the migration handles existing duplicates gracefully.
@WorkspaceIsUnique() | ||
[EMAILS_FIELD_NAME]: EmailsMetadata; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: This unique constraint may cause issues with soft-deleted records - ensure the uniqueness check excludes soft-deleted entries
@@ -25,7 +25,9 @@ export function WorkspaceIndex( | |||
); | |||
|
|||
metadataArgsStorage.addIndexes({ | |||
name: `IDX_${generateDeterministicIndexName([ | |||
name: `IDX_${ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we want that. I added IDX_UNIQUE so that we could differentiate field-level unicity constraints from the indexes that are managed directly. It probably doesn't matter a lot in either case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Context