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

refactor(entities): centralize base entity fields #10287

Closed
wants to merge 1 commit into from

Conversation

AMoreaux
Copy link
Contributor

Extracted common fields (id, createdAt, updatedAt, deletedAt) into abstract base classes BaseEntity and BaseSoftDeleteEntity. Updated various entities to inherit from these classes, reducing redundancy and improving maintainability.

Extracted common fields (id, createdAt, updatedAt, deletedAt) into abstract base classes BaseEntity and BaseSoftDeleteEntity. Updated various entities to inherit from these classes, reducing redundancy and improving maintainability.
@AMoreaux AMoreaux self-assigned this Feb 18, 2025
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

Introduced abstract base classes to centralize common entity fields across the codebase, improving code maintainability and reducing duplication in the Twenty server.

  • Added new src/engine/utils/base-entities-fields.ts with BaseEntity and BaseSoftDeleteEntity classes to handle common fields (id, timestamps)
  • Refactored WorkspaceSSOIdentityProvider, AppToken, User, and Workspace entities to inherit from base classes
  • Maintained unique email index with deletedAt condition in User entity
  • Preserved GraphQL decorators and TypeORM relationships across all modified entities
  • Ensured proper field types with timestamptz for all date columns

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

Comment on lines 33 to 35
@OneToMany(() => AppToken, (appToken) => appToken.workspace, {
cascade: true,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

style: cascade:true with onDelete:CASCADE in other relations may cause duplicate cascade operations

Comment on lines +30 to +32
@Field({ nullable: true })
@DeleteDateColumn({ name: 'deletedAt', type: 'timestamptz' })
deletedAt: Date;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: deletedAt field should be nullable in the database column as well. Add nullable: true to @DeleteDateColumn options

Suggested change
@Field({ nullable: true })
@DeleteDateColumn({ name: 'deletedAt', type: 'timestamptz' })
deletedAt: Date;
@Field({ nullable: true })
@DeleteDateColumn({ name: 'deletedAt', type: 'timestamptz', nullable: true })
deletedAt: Date;

@AMoreaux AMoreaux closed this Feb 18, 2025
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