Fix seeds (#7543)
- Fixing seeds after introducing the requirement for non-nullable fields to have a default value (https://github.com/twentyhq/twenty/pull/7522). - Empty string needs to be considered a valid default value
This commit is contained in:
@ -15,6 +15,7 @@ export const getDevSeedCompanyCustomFields = (
|
|||||||
icon: 'IconAdCircle',
|
icon: 'IconAdCircle',
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isNullable: false,
|
isNullable: false,
|
||||||
|
defaultValue: "''",
|
||||||
objectMetadataId,
|
objectMetadataId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -99,6 +100,13 @@ export const getDevSeedPeopleCustomFields = (
|
|||||||
icon: 'IconBrandWhatsapp',
|
icon: 'IconBrandWhatsapp',
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isNullable: false,
|
isNullable: false,
|
||||||
|
defaultValue: [
|
||||||
|
{
|
||||||
|
primaryPhoneNumber: '',
|
||||||
|
primaryPhoneCountryCode: '',
|
||||||
|
additionalPhones: {},
|
||||||
|
},
|
||||||
|
],
|
||||||
objectMetadataId,
|
objectMetadataId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -55,6 +55,7 @@ import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.
|
|||||||
import { computeObjectTargetTable } from 'src/engine/utils/compute-object-target-table.util';
|
import { computeObjectTargetTable } from 'src/engine/utils/compute-object-target-table.util';
|
||||||
import { WorkspaceMigrationRunnerService } from 'src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service';
|
import { WorkspaceMigrationRunnerService } from 'src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service';
|
||||||
import { ViewFieldWorkspaceEntity } from 'src/modules/view/standard-objects/view-field.workspace-entity';
|
import { ViewFieldWorkspaceEntity } from 'src/modules/view/standard-objects/view-field.workspace-entity';
|
||||||
|
import { isDefined } from 'src/utils/is-defined';
|
||||||
|
|
||||||
import { FieldMetadataValidationService } from './field-metadata-validation.service';
|
import { FieldMetadataValidationService } from './field-metadata-validation.service';
|
||||||
import {
|
import {
|
||||||
@ -746,7 +747,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fieldMetadataInput.isNullable) {
|
if (!fieldMetadataInput.isNullable) {
|
||||||
if (!fieldMetadataInput.defaultValue) {
|
if (!isDefined(fieldMetadataInput.defaultValue)) {
|
||||||
throw new FieldMetadataException(
|
throw new FieldMetadataException(
|
||||||
'Default value is required for non nullable fields',
|
'Default value is required for non nullable fields',
|
||||||
FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||||
|
|||||||
Reference in New Issue
Block a user