-
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
Deprecate address standard field #6087
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
- 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 toWorkspaceFieldMetadataArgs
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) { |
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.
I don't understand what this was for, we were comparing name with ids (fieldName is an id)
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.
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( |
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.
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
@@ -41,7 +41,7 @@ export class EntityEventsToDbListener { | |||
// .... | |||
|
|||
private async handle(payload: ObjectRecordBaseEvent) { | |||
if (!payload.objectMetadata.isAuditLogged) { | |||
if (!payload.objectMetadata?.isAuditLogged) { |
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.
Mmm, objectMetadata should always be defined I believe, did you have an issue locally?
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.
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
...c/engine/workspace-manager/workspace-sync-metadata/comparators/workspace-field.comparator.ts
Outdated
Show resolved
Hide resolved
@@ -108,10 +114,6 @@ export class WorkspaceFieldComparator { | |||
const findField = ( | |||
field: ComputedPartialFieldMetadata | FieldMetadataEntity, | |||
) => { | |||
if (field.isCustom) { |
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.
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)
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.
LGTM, good job! 👏 @ijreilly
@WorkspaceField({ | ||
standardId: COMPANY_STANDARD_FIELD_IDS.address_deprecated, | ||
type: FieldMetadataType.TEXT, | ||
label: 'Address (deprecated) ', |
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.
@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)
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.
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."
Fix a small bug introduced in #6087 preventing database reset
Closes #5916