fix: empty string as default value for string types (#2691)

* fix: empty string as default value for string types

* Fixes

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Jérémy M 2023-11-24 16:30:28 +01:00 committed by GitHub
parent 0376d0b7e0
commit 2b597d817c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 9 deletions

View File

@ -36,7 +36,7 @@ export function convertFieldMetadataToColumnActions(
action: WorkspaceMigrationColumnActionType.CREATE,
columnName: fieldMetadata.targetColumnMap.value,
columnType: 'text',
defaultValue: serializeDefaultValue(defaultValue?.value),
defaultValue: serializeDefaultValue(defaultValue?.value ?? ''),
},
];
}
@ -52,7 +52,7 @@ export function convertFieldMetadataToColumnActions(
action: WorkspaceMigrationColumnActionType.CREATE,
columnName: fieldMetadata.targetColumnMap.value,
columnType: 'varchar',
defaultValue: serializeDefaultValue(defaultValue?.value),
defaultValue: serializeDefaultValue(defaultValue?.value ?? ''),
},
];
}
@ -120,13 +120,13 @@ export function convertFieldMetadataToColumnActions(
action: WorkspaceMigrationColumnActionType.CREATE,
columnName: fieldMetadata.targetColumnMap.label,
columnType: 'varchar',
defaultValue: serializeDefaultValue(defaultValue?.label),
defaultValue: serializeDefaultValue(defaultValue?.label ?? ''),
},
{
action: WorkspaceMigrationColumnActionType.CREATE,
columnName: fieldMetadata.targetColumnMap.url,
columnType: 'varchar',
defaultValue: serializeDefaultValue(defaultValue?.url),
defaultValue: serializeDefaultValue(defaultValue?.url ?? ''),
},
];
}
@ -146,7 +146,7 @@ export function convertFieldMetadataToColumnActions(
action: WorkspaceMigrationColumnActionType.CREATE,
columnName: fieldMetadata.targetColumnMap.currencyCode,
columnType: 'varchar',
defaultValue: serializeDefaultValue(defaultValue?.currencyCode),
defaultValue: serializeDefaultValue(defaultValue?.currencyCode ?? ''),
},
];
}
@ -159,13 +159,13 @@ export function convertFieldMetadataToColumnActions(
action: WorkspaceMigrationColumnActionType.CREATE,
columnName: fieldMetadata.targetColumnMap.firstName,
columnType: 'varchar',
defaultValue: serializeDefaultValue(defaultValue?.firstName),
defaultValue: serializeDefaultValue(defaultValue?.firstName ?? ''),
},
{
action: WorkspaceMigrationColumnActionType.CREATE,
columnName: fieldMetadata.targetColumnMap.lastName,
columnType: 'varchar',
defaultValue: serializeDefaultValue(defaultValue?.lastName),
defaultValue: serializeDefaultValue(defaultValue?.lastName ?? ''),
},
];
}

View File

@ -39,21 +39,25 @@ export const addCompanyTable: WorkspaceMigrationTableAction[] = [
columnName: 'linkedinLinkUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'linkedinLinkLabel',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'xLinkUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'xLinkLabel',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'annualRecurringRevenueAmountMicros',

View File

@ -19,7 +19,7 @@ export const addViewFieldTable: WorkspaceMigrationTableAction[] = [
},
{
columnName: 'position',
columnType: 'integer',
columnType: 'float',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: 0,
},

View File

@ -22,7 +22,7 @@ export const addActivityTable: WorkspaceMigrationTableAction[] = [
columnName: 'body',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
defaultValue: "'{}'",
},
{
columnName: 'type',

View File

@ -16,6 +16,7 @@ export const addApiKeyTable: WorkspaceMigrationTableAction[] = [
columnName: 'name',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'revokedAt',

View File

@ -28,46 +28,55 @@ export const addPersonTable: WorkspaceMigrationTableAction[] = [
columnName: 'email',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'linkedinLinkUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'linkedinLinkLabel',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'xLinkUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'xLinkLabel',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'jobTitle',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'phone',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'city',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'avatarUrl',
columnType: 'varchar',
action: WorkspaceMigrationColumnActionType.CREATE,
defaultValue: "''",
},
{
columnName: 'companyId',