From e19e7a816f59da365d676de7c9527ad01d0d5ba1 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Fri, 17 Nov 2023 12:01:56 +0100 Subject: [PATCH] Update seeds to take currency and link type into account --- .../metadata/field-metadata/company.ts | 5 +++-- .../metadata/field-metadata/opportunity.ts | 5 +++-- .../metadata/field-metadata/person.ts | 14 ++++++++------ .../migrations/1697618009-addCompanyTable.ts | 11 ++++++++--- .../migrations/1697618021-addOpportunityTable.ts | 9 +++++++-- .../migrations/1697618022-addPersonTable.ts | 14 ++++++++++++-- .../workspace-manager/standard-objects/company.ts | 11 +++++++---- .../standard-objects/opportunity.ts | 5 +++-- 8 files changed, 51 insertions(+), 23 deletions(-) diff --git a/server/src/database/typeorm-seeds/metadata/field-metadata/company.ts b/server/src/database/typeorm-seeds/metadata/field-metadata/company.ts index 00eecfb15e..e32195ef30 100644 --- a/server/src/database/typeorm-seeds/metadata/field-metadata/company.ts +++ b/server/src/database/typeorm-seeds/metadata/field-metadata/company.ts @@ -230,11 +230,12 @@ export const seedCompanyFieldMetadata = async ( isCustom: false, workspaceId: SeedWorkspaceId, isActive: true, - type: FieldMetadataType.NUMBER, + type: FieldMetadataType.CURRENCY, name: 'annualRecurringRevenue', label: 'ARR', targetColumnMap: { - value: 'annualRecurringRevenue', + amountMicros: 'annualRecurringRevenueAmountMicros', + currencyCode: 'annualRecurringRevenueCurrencyCode', }, description: 'Annual Recurring Revenue: The actual or estimated annual revenue of the company', diff --git a/server/src/database/typeorm-seeds/metadata/field-metadata/opportunity.ts b/server/src/database/typeorm-seeds/metadata/field-metadata/opportunity.ts index 28e6537c04..69f00c8f82 100644 --- a/server/src/database/typeorm-seeds/metadata/field-metadata/opportunity.ts +++ b/server/src/database/typeorm-seeds/metadata/field-metadata/opportunity.ts @@ -112,11 +112,12 @@ export const seedOpportunityFieldMetadata = async ( isCustom: false, workspaceId: SeedWorkspaceId, isActive: true, - type: FieldMetadataType.NUMBER, + type: FieldMetadataType.CURRENCY, name: 'amount', label: 'Amount', targetColumnMap: { - value: 'amount', + amountMicros: 'amountAmountMicros', + currencyCode: 'amountCurrencyCode', }, description: 'Opportunity amount', icon: 'IconCurrencyDollar', diff --git a/server/src/database/typeorm-seeds/metadata/field-metadata/person.ts b/server/src/database/typeorm-seeds/metadata/field-metadata/person.ts index 67b645c983..801f993cb2 100644 --- a/server/src/database/typeorm-seeds/metadata/field-metadata/person.ts +++ b/server/src/database/typeorm-seeds/metadata/field-metadata/person.ts @@ -174,11 +174,12 @@ export const seedPersonFieldMetadata = async ( isCustom: false, workspaceId: SeedWorkspaceId, isActive: true, - type: FieldMetadataType.TEXT, - name: 'linkedinUrl', + type: FieldMetadataType.LINK, + name: 'linkedinLink', label: 'Linkedin', targetColumnMap: { - value: 'linkedinUrl', + label: 'linkedinLinkLabel', + url: 'linkedinLinkUrl', }, description: 'Contact’s Linkedin account', icon: 'IconBrandLinkedin', @@ -192,11 +193,12 @@ export const seedPersonFieldMetadata = async ( isCustom: false, workspaceId: SeedWorkspaceId, isActive: true, - type: FieldMetadataType.TEXT, - name: 'xUrl', + type: FieldMetadataType.LINK, + name: 'xLink', label: 'X', targetColumnMap: { - value: 'xUrl', + label: 'xLinkLabel', + url: 'xLinkUrl', }, description: 'Contact’s X/Twitter account', icon: 'IconUser', diff --git a/server/src/metadata/workspace-migration/migrations/1697618009-addCompanyTable.ts b/server/src/metadata/workspace-migration/migrations/1697618009-addCompanyTable.ts index 0182e96879..995920aa4c 100644 --- a/server/src/metadata/workspace-migration/migrations/1697618009-addCompanyTable.ts +++ b/server/src/metadata/workspace-migration/migrations/1697618009-addCompanyTable.ts @@ -33,7 +33,7 @@ export const addCompanyTable: WorkspaceMigrationTableAction[] = [ action: WorkspaceMigrationColumnActionType.CREATE, }, { - columnName: 'linkedinLinklUrl', + columnName: 'linkedinLinkUrl', columnType: 'varchar', action: WorkspaceMigrationColumnActionType.CREATE, }, @@ -53,8 +53,13 @@ export const addCompanyTable: WorkspaceMigrationTableAction[] = [ action: WorkspaceMigrationColumnActionType.CREATE, }, { - columnName: 'annualRecurringRevenue', - columnType: 'float', + columnName: 'annualRecurringRevenueAmountMicros', + columnType: 'integer', + action: WorkspaceMigrationColumnActionType.CREATE, + }, + { + columnName: 'annualRecurringRevenueCurrencyCode', + columnType: 'varchar', action: WorkspaceMigrationColumnActionType.CREATE, }, { diff --git a/server/src/metadata/workspace-migration/migrations/1697618021-addOpportunityTable.ts b/server/src/metadata/workspace-migration/migrations/1697618021-addOpportunityTable.ts index bf6f0becf3..5d0b6bc2c6 100644 --- a/server/src/metadata/workspace-migration/migrations/1697618021-addOpportunityTable.ts +++ b/server/src/metadata/workspace-migration/migrations/1697618021-addOpportunityTable.ts @@ -13,8 +13,13 @@ export const addOpportunityTable: WorkspaceMigrationTableAction[] = [ action: 'alter', columns: [ { - columnName: 'amount', - columnType: 'float', + columnName: 'amountAmountMicros', + columnType: 'integer', + action: WorkspaceMigrationColumnActionType.CREATE, + }, + { + columnName: 'amountCurrencyCode', + columnType: 'varchar', action: WorkspaceMigrationColumnActionType.CREATE, }, { diff --git a/server/src/metadata/workspace-migration/migrations/1697618022-addPersonTable.ts b/server/src/metadata/workspace-migration/migrations/1697618022-addPersonTable.ts index e05f0ab6eb..628bd196f4 100644 --- a/server/src/metadata/workspace-migration/migrations/1697618022-addPersonTable.ts +++ b/server/src/metadata/workspace-migration/migrations/1697618022-addPersonTable.ts @@ -28,12 +28,22 @@ export const addPersonTable: WorkspaceMigrationTableAction[] = [ action: WorkspaceMigrationColumnActionType.CREATE, }, { - columnName: 'linkedinUrl', + columnName: 'linkedinLinkUrl', columnType: 'varchar', action: WorkspaceMigrationColumnActionType.CREATE, }, { - columnName: 'xUrl', + columnName: 'linkedinLinkLabel', + columnType: 'varchar', + action: WorkspaceMigrationColumnActionType.CREATE, + }, + { + columnName: 'xLinkUrl', + columnType: 'varchar', + action: WorkspaceMigrationColumnActionType.CREATE, + }, + { + columnName: 'xLinkLabel', columnType: 'varchar', action: WorkspaceMigrationColumnActionType.CREATE, }, diff --git a/server/src/workspace/workspace-manager/standard-objects/company.ts b/server/src/workspace/workspace-manager/standard-objects/company.ts index 6fc3c74ba6..db0ece752e 100644 --- a/server/src/workspace/workspace-manager/standard-objects/company.ts +++ b/server/src/workspace/workspace-manager/standard-objects/company.ts @@ -71,7 +71,8 @@ const companyMetadata = { name: 'linkedinLink', label: 'Linkedin', targetColumnMap: { - value: 'linkedinLink', + label: 'linkedinLinkLabel', + url: 'linkedinLinkUrl', }, description: 'The company Linkedin account', icon: 'IconBrandLinkedin', @@ -84,7 +85,8 @@ const companyMetadata = { name: 'xLink', label: 'X', targetColumnMap: { - value: 'xLink', + label: 'xLinkLabel', + url: 'xLinkUrl', }, description: 'The company Twitter/X account', icon: 'IconBrandX', @@ -93,11 +95,12 @@ const companyMetadata = { { isCustom: false, isActive: true, - type: FieldMetadataType.NUMBER, + type: FieldMetadataType.CURRENCY, name: 'annualRecurringRevenue', label: 'ARR', targetColumnMap: { - value: 'annualRecurringRevenue', + amountMicros: 'annualRecurringRevenueAmountMicros', + currencyCode: 'annualRecurringRevenueCurrencyCode', }, description: 'Annual Recurring Revenue: The actual or estimated annual revenue of the company', diff --git a/server/src/workspace/workspace-manager/standard-objects/opportunity.ts b/server/src/workspace/workspace-manager/standard-objects/opportunity.ts index d2a73acbde..b0a923eb8a 100644 --- a/server/src/workspace/workspace-manager/standard-objects/opportunity.ts +++ b/server/src/workspace/workspace-manager/standard-objects/opportunity.ts @@ -14,11 +14,12 @@ const opportunityMetadata = { { isCustom: false, isActive: true, - type: FieldMetadataType.NUMBER, + type: FieldMetadataType.CURRENCY, name: 'amount', label: 'Amount', targetColumnMap: { - value: 'amount', + amountMicros: 'amountAmountMicros', + currencyCode: 'amountCurrencyCode', }, description: 'Opportunity amount', icon: 'IconCurrencyDollar',