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

Enforce unique constraints for 0.33 #8645

Merged
merged 6 commits into from
Nov 21, 2024
Merged

Conversation

Weiko
Copy link
Member

@Weiko Weiko commented Nov 21, 2024

Context

  • Fixing folder structure where 0.33 was inside 0.32.
  • Updating the command so it runs enforce uniqueness on all tables
  • Updating workspaces entities so the sync metadata adds the index

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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

Comment on lines 36 to 46
await this.enforceUniqueConstraintsCommand.executeActiveWorkspacesCommand(
passedParam,
{
...options,
company: true,
person: true,
viewField: false,
viewSort: false,
},
workspaceIds,
);
Copy link
Contributor

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

Comment on lines 79 to 80
@WorkspaceIsUnique()
*/
[DOMAIN_NAME_FIELD_NAME]?: LinksMetadata;
Copy link
Contributor

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.

Comment on lines +84 to 85
@WorkspaceIsUnique()
[EMAILS_FIELD_NAME]: EmailsMetadata;
Copy link
Contributor

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

@Weiko
Copy link
Member Author

Weiko commented Nov 21, 2024

cc @FelixMalfait

@@ -25,7 +25,9 @@ export function WorkspaceIndex(
);

metadataArgsStorage.addIndexes({
name: `IDX_${generateDeterministicIndexName([
name: `IDX_${
Copy link
Member

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

Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

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

Great!

@Weiko Weiko merged commit 52df530 into main Nov 21, 2024
19 checks passed
@Weiko Weiko deleted the c--enforce-unique-constraints-for-0-33 branch November 21, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants