-
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
Migrate domainName field from text type to links type #6410
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
The pull request migrates the domainName
field from a text type to a links type, allowing for multiple domain values.
- CommandMenu.tsx: Updated to use
getCompanyDomainName
for fetching company logos. - Company.ts: Changed
domainName
field to support both string and link object types. - mapFavorites.ts: Adapted to use
getCompanyDomainName
for avatar URLs. - 0-23-migrate-domain-to-links.command.ts: Added migration command for
domainName
field. - quick-actions.service.ts: Updated
enrichCompany
method to handle new linked field type.
19 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
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
(updates since last review)
The pull request migrates the domainName
field from a text type to a links type, enhancing the ability to handle multiple domain values.
- packages/twenty-server/src/database/commands/upgrade-version/0-23/0-23-migrate-domain-to-links.command.ts: Introduces a comprehensive migration command with error handling and rollback mechanisms.
- packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts: Integrates
TwentyORMGlobalManager
for repository operations, improving data access consistency. - packages/twenty-server/src/engine/twenty-orm/factories/workspace-datasource.factory.ts: Simplifies cache version logic using nullish coalescing operator.
- packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-object-metadata-identifiers.service.ts: Adds null check for
standardId
to enhance metadata retrieval robustness. - packages/twenty-front/src/modules/object-record/utils/sanitizeRecordInput.ts: Removes
getCompanyDomainName
dependency, simplifyingdomainName
sanitization logic.
14 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
dataSourceMetadata: DataSourceEntity; | ||
}) { | ||
await workspaceQueryRunner.query( | ||
`UPDATE "${dataSourceMetadata.schema}"."company" SET "${targetColumnName}" = CASE WHEN "${sourceColumnName}" LIKE 'https://%' THEN "${sourceColumnName}" ELSE 'https://' || "${sourceColumnName}" END;`, |
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.
is 'https' a requirement for LINKS fields? I'm wondering if we really want to do that otherwise? Also it might overwrite to "https://http://www.google.com" (unlikely though)
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 think we really want to have that https:// prefix, we add it in the front-end.
Maybe I could replace LIKE 'https://%'
with LIKE 'http'
to be extra safe
}); | ||
|
||
// Backfill primaryLinkLabel with empty string | ||
await this.backfillColumnWithEmptyString({ |
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.
Do we need to set empty string? I thought this column would have a defaultValue already
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.
Oh you are right ! I added the defaultValue logic after, so until then I needed this. removing it now thanks
@@ -0,0 +1,8 @@ | |||
// temporary, to remove once domainName has been fully migrated to Links type | |||
export const getCompanyDomainName = (company: any) => { |
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.
Seems this one is not aligned with getCompanyDomainName from front package
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.
right, thanks
@@ -10,6 +10,10 @@ type FieldMetadataDefaultSettings = { | |||
isForeignKey?: boolean; | |||
}; | |||
|
|||
type FieldMetadataLinksSettings = { | |||
isDomain?: boolean; |
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.
Do we want to introduce this in this PR? I don't see where this is used
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.
Right it's not actually
@@ -159,7 +161,7 @@ export class QuickActionsService { | |||
} | |||
|
|||
const enrichedData = await this.intelligenceService.enrichCompany( | |||
company.domainName, | |||
getCompanyNameFromDomainName(getCompanyDomainName(company.domainName)), |
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 used to work with domainName only, why do we want the name of the company now?
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.
its a mistake, thanks for spotting this. (i think this service is not in use anymore by the way)
VALUES ($1, $2, $3, $4, $5)`, | ||
[ | ||
companyToCreate.id, | ||
companyToCreate.domainName, | ||
'https://' + companyToCreate.domainName, |
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.
Why do we add 'https://' here but we don't in getExistingCompaniesByDomainNames
? The get and the create should have a consistant api, either companyToCreate
and domainNames
should both contain https://
or they shouldn't.
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 had not paid attention to that, thanks.
I am replacing the query to compare the domain names without the 'https://' or 'http://' prefix; this seems safer than adding the prefix the domainNames and comparing. (although when we migrate the existing data we are adding https:// so all existing data should have a https:// prefix but still)
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.
yet to test though, waiting on your help on how to trigger sync 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.
tested !
@@ -23,7 +23,7 @@ export const companyPrefillData = async ( | |||
.values([ | |||
{ | |||
name: 'Airbnb', | |||
domainName: 'airbnb.com', | |||
domainNamePrimaryLinkUrl: 'airbnb.com', |
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.
https://
?
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, great job @ijreilly! 👏
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
Closes #5759.