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

Fix 0.32 #8319

Merged
merged 1 commit into from
Nov 4, 2024
Merged

Fix 0.32 #8319

merged 1 commit into from
Nov 4, 2024

Conversation

charlesBochet
Copy link
Member

@charlesBochet charlesBochet commented Nov 4, 2024

  • Removing unique constraint creation in 0.32 as we have a dependency on sync-metadata and sync-metadata has a dependency on it if we keep it.
  • sync-metadata does not support well the deletion of activity + activityTarget, silently swallow the exception for now

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 changes to enforce unique constraints for person emails in version 0.32, with related adjustments to foreign key handling and entity definitions.

  • Removes optional flag for person email uniqueness in /packages/twenty-server/src/database/commands/upgrade-version/0-32/0-32-enforce-unique-constraints.command.ts, making it mandatory
  • Adds temporary workaround in workspace-migration-runner.service.ts to handle missing 'activityId' foreign key during 0.32 upgrade
  • Shifts from decorator-based to database-level uniqueness by removing @WorkspaceIsUnique() from person.workspace-entity.ts
  • Handles duplicate emails by appending incremental numbers while preserving the original email structure
  • Includes migration script to safely update existing duplicate records without data loss

3 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +525 to +528
// Todo: Remove this temporary hack tied to 0.32 upgrade
if (migrationColumn.columnName === 'activityId') {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: This temporary hack silently ignores missing foreign key constraints for activityId columns. Consider adding logging to track these occurrences.

Comment on lines +83 to 84
// @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.

style: Consider removing the commented-out decorator entirely instead of leaving it as a comment, since the uniqueness is now handled by the migration script

Comment on lines +83 to 84
// @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: Removing uniqueness constraint on emails could allow duplicate contacts to be created - ensure proper validation is implemented at the application level

@charlesBochet charlesBochet merged commit 4fc690b into main Nov 4, 2024
19 checks passed
@charlesBochet charlesBochet deleted the fix-0-32 branch November 4, 2024 21:08
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.

1 participant