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

Deprecate address standard field #6087

Merged
merged 16 commits into from
Jul 10, 2024
Merged

Deprecate address standard field #6087

merged 16 commits into from
Jul 10, 2024

Conversation

ijreilly
Copy link
Collaborator

@ijreilly ijreilly commented Jul 1, 2024

Closes #5916

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

  • Updated 'Address' field type in /packages/twenty-front/src/modules/sign-in-background-mock/constants/SignInBackgroundMockColumnDefinitions.ts and /packages/twenty-front/src/modules/sign-in-background-mock/constants/SignInBackgroundMockFilterDefinitions.ts
  • Added isDeprecated property to WorkspaceFieldMetadataArgs in /packages/twenty-server/src/engine/twenty-orm/interfaces/workspace-field-metadata-args.interface.ts
  • Introduced WorkspaceIsDeprecated decorator in /packages/twenty-server/src/engine/twenty-orm/decorators/workspace-is-deprecated.decorator.ts
  • Deprecated 'address' field in company prefill data in /packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/company.ts
  • Modified synchronization logic to handle deprecated fields in /packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-field-metadata.service.ts

17 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@@ -108,10 +114,6 @@ export class WorkspaceFieldComparator {
const findField = (
field: ComputedPartialFieldMetadata | FieldMetadataEntity,
) => {
if (field.isCustom) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't understand what this was for, we were comparing name with ids (fieldName is an id)

Copy link
Member

Choose a reason for hiding this comment

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

It's because custom fields don't have standard ids so I guess the comparison was made with field.name instead.
It's more confusing to have field.standardId === fieldName since as you said one is an id and the other one is a text 🤔 (Maybe @magrinj has more context on this part, I'm wondering if we really can remove this code. I'll double check on my side)

/**
* Create field metadata
*/
const createdFieldMetadataCollection = await fieldMetadataRepository.save(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Inverted create and update because when deprecating a field and creating a new one with the deprecated field's former name, we first need the deprecated field to be renamed before we can create a new one with the previous name

@ijreilly ijreilly changed the title [POC] Deprecate address field Deprecate address standard field Jul 4, 2024
@@ -41,7 +41,7 @@ export class EntityEventsToDbListener {
// ....

private async handle(payload: ObjectRecordBaseEvent) {
if (!payload.objectMetadata.isAuditLogged) {
if (!payload.objectMetadata?.isAuditLogged) {
Copy link
Member

Choose a reason for hiding this comment

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

Mmm, objectMetadata should always be defined I believe, did you have an issue locally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I had it, but I think it was when there was an error with the refacto that was fixed afterwards. I will remove it

@@ -108,10 +114,6 @@ export class WorkspaceFieldComparator {
const findField = (
field: ComputedPartialFieldMetadata | FieldMetadataEntity,
) => {
if (field.isCustom) {
Copy link
Member

Choose a reason for hiding this comment

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

It's because custom fields don't have standard ids so I guess the comparison was made with field.name instead.
It's more confusing to have field.standardId === fieldName since as you said one is an id and the other one is a text 🤔 (Maybe @magrinj has more context on this part, I'm wondering if we really can remove this code. I'll double check on my side)

Copy link
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

LGTM, good job! 👏 @ijreilly

@ijreilly ijreilly merged commit 34d13a7 into main Jul 10, 2024
13 of 14 checks passed
@ijreilly ijreilly deleted the explo-convert-company branch July 10, 2024 16:07
@WorkspaceField({
standardId: COMPANY_STANDARD_FIELD_IDS.address_deprecated,
type: FieldMetadataType.TEXT,
label: 'Address (deprecated) ',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Bonapara @FelixMalfait are you ok with this? or would you want a different naming? (it's the label so they can still change it again)
image

Copy link
Member

Choose a reason for hiding this comment

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

Address (Deprecated) seems good to me! Ideally, I wonder if we could also prepend the field description with:

"This standard field has been deprecated and migrated as a custom field. Please consider using the new 'address' field type."

FelixMalfait added a commit that referenced this pull request Jul 11, 2024
Fix a small bug introduced in
#6087 preventing database reset
@charlesBochet charlesBochet mentioned this pull request Jul 11, 2024
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.

[Timebox] Convert Company's address field to Address type
4 participants