Skip to content

Commit

Permalink
Fix seeds (twentyhq#7543)
Browse files Browse the repository at this point in the history
- Fixing seeds after introducing the requirement for non-nullable fields
to have a default value (twentyhq#7522).
- Empty string needs to be considered a valid default value
  • Loading branch information
ijreilly authored and harshit078 committed Oct 14, 2024
1 parent 2c117fd commit 2bc392a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const getDevSeedCompanyCustomFields = (
icon: 'IconAdCircle',
isActive: true,
isNullable: false,
defaultValue: "''",
objectMetadataId,
},
{
Expand Down Expand Up @@ -99,6 +100,13 @@ export const getDevSeedPeopleCustomFields = (
icon: 'IconBrandWhatsapp',
isActive: true,
isNullable: false,
defaultValue: [
{
primaryPhoneNumber: '',
primaryPhoneCountryCode: '',
additionalPhones: {},
},
],
objectMetadataId,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 { 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 { isDefined } from 'src/utils/is-defined';

import { FieldMetadataValidationService } from './field-metadata-validation.service';
import {
Expand Down Expand Up @@ -746,7 +747,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
}

if (!fieldMetadataInput.isNullable) {
if (!fieldMetadataInput.defaultValue) {
if (!isDefined(fieldMetadataInput.defaultValue)) {
throw new FieldMetadataException(
'Default value is required for non nullable fields',
FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
Expand Down

0 comments on commit 2bc392a

Please sign in to comment.