mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-23 05:53:31 +03:00
Fix email migration (#7298)
Checks if person standard email field exists before running the migration.
This commit is contained in:
parent
e28d8dd952
commit
942281f4b0
@ -305,14 +305,6 @@ export class MigrateEmailFieldsToEmailsCommand extends ActiveWorkspacesCommandRu
|
|||||||
) {
|
) {
|
||||||
this.logger.log(`Migrating person email field of type EMAIL to EMAILS`);
|
this.logger.log(`Migrating person email field of type EMAIL to EMAILS`);
|
||||||
|
|
||||||
await this.migrateDataWithinTable({
|
|
||||||
sourceColumnName: 'email',
|
|
||||||
targetColumnName: 'emailsPrimaryEmail',
|
|
||||||
tableName: 'person',
|
|
||||||
workspaceQueryRunner,
|
|
||||||
dataSourceMetadata,
|
|
||||||
});
|
|
||||||
|
|
||||||
const personEmailFieldMetadata = await this.fieldMetadataRepository.findOne(
|
const personEmailFieldMetadata = await this.fieldMetadataRepository.findOne(
|
||||||
{
|
{
|
||||||
where: {
|
where: {
|
||||||
@ -322,6 +314,22 @@ export class MigrateEmailFieldsToEmailsCommand extends ActiveWorkspacesCommandRu
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!personEmailFieldMetadata) {
|
||||||
|
this.logger.log(
|
||||||
|
`Could not find person email field with standardId ${PERSON_STANDARD_FIELD_IDS.email}, skipping migration`,
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.migrateDataWithinTable({
|
||||||
|
sourceColumnName: 'email',
|
||||||
|
targetColumnName: 'emailsPrimaryEmail',
|
||||||
|
tableName: 'person',
|
||||||
|
workspaceQueryRunner,
|
||||||
|
dataSourceMetadata,
|
||||||
|
});
|
||||||
|
|
||||||
if (personEmailFieldMetadata) {
|
if (personEmailFieldMetadata) {
|
||||||
await this.fieldMetadataService.deleteOneField(
|
await this.fieldMetadataService.deleteOneField(
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user