Fix Tasks/Notes created with null position (#9068)
Fixes https://github.com/twentyhq/twenty/issues/8810 Fixes https://github.com/twentyhq/twenty/issues/5268 Fixes https://github.com/twentyhq/twenty/issues/8971 - Fixing Task/Note creation not sending position during creation - Adding a command to backfill position being null, using existing backfill command. - Removed unused backfill job. - Updated workspace entities to set position non-nullable and set a default value to make it non-required on the API - Updated position factory to set a default position for all objects having a POSITION field instead of only company/people - Moved the try/catch in each resolver factory calling GraphqlQueryRunnerException handler, makes more sense to call it in the actual graphql-query-runner and removing some duplicate codes - Adding validations for input in QueryRunnerArgs factories - Allow sync-metadata to override and sync defaultValues for certain field types (that can't be updated by users) - Removing health-check from sync-metadata command during force mode to improve performances
This commit is contained in:
@ -50,40 +50,43 @@ export class SyncWorkspaceMetadataCommand extends ActiveWorkspacesCommandRunner
|
||||
`Running workspace sync for workspace: ${workspaceId} (${count} out of ${workspaceIds.length})`,
|
||||
);
|
||||
count++;
|
||||
try {
|
||||
const issues =
|
||||
await this.workspaceHealthService.healthCheck(workspaceId);
|
||||
|
||||
// Security: abort if there are issues.
|
||||
if (issues.length > 0) {
|
||||
if (!options.force) {
|
||||
try {
|
||||
const issues =
|
||||
await this.workspaceHealthService.healthCheck(workspaceId);
|
||||
|
||||
// Security: abort if there are issues.
|
||||
if (issues.length > 0) {
|
||||
if (!options.force) {
|
||||
this.logger.error(
|
||||
`Workspace contains ${issues.length} issues, aborting.`,
|
||||
);
|
||||
|
||||
this.logger.log(
|
||||
'If you want to force the migration, use --force flag',
|
||||
);
|
||||
this.logger.log(
|
||||
'Please use `workspace:health` command to check issues and fix them before running this command.',
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
this.logger.warn(
|
||||
`Workspace contains ${issues.length} issues, sync has been forced.`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
if (!options.force) {
|
||||
this.logger.error(
|
||||
`Workspace contains ${issues.length} issues, aborting.`,
|
||||
);
|
||||
|
||||
this.logger.log(
|
||||
'If you want to force the migration, use --force flag',
|
||||
);
|
||||
this.logger.log(
|
||||
'Please use `workspace:health` command to check issues and fix them before running this command.',
|
||||
);
|
||||
|
||||
continue;
|
||||
throw error;
|
||||
}
|
||||
|
||||
this.logger.warn(
|
||||
`Workspace contains ${issues.length} issues, sync has been forced.`,
|
||||
`Workspace health check failed with error, but sync has been forced.`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
if (!options.force) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
this.logger.warn(
|
||||
`Workspace health check failed with error, but sync has been forced.`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@ -8,7 +8,10 @@ import {
|
||||
} from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/comparator.interface';
|
||||
import { ComputedPartialFieldMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/partial-field-metadata.interface';
|
||||
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import {
|
||||
FieldMetadataEntity,
|
||||
FieldMetadataType,
|
||||
} from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { transformMetadataForComparison } from 'src/engine/workspace-manager/workspace-sync-metadata/comparators/utils/transform-metadata-for-comparison.util';
|
||||
|
||||
const commonFieldPropertiesToIgnore = [
|
||||
@ -24,10 +27,24 @@ const commonFieldPropertiesToIgnore = [
|
||||
'asExpression',
|
||||
'generatedType',
|
||||
'defaultValue',
|
||||
'isLabelSyncedWithName',
|
||||
];
|
||||
|
||||
const fieldPropertiesToStringify = ['defaultValue'] as const;
|
||||
|
||||
const shouldNotOverrideDefaultValue = (
|
||||
fieldMetadata: FieldMetadataEntity | ComputedPartialFieldMetadata,
|
||||
) => {
|
||||
return [
|
||||
FieldMetadataType.BOOLEAN,
|
||||
FieldMetadataType.SELECT,
|
||||
FieldMetadataType.MULTI_SELECT,
|
||||
FieldMetadataType.CURRENCY,
|
||||
FieldMetadataType.PHONES,
|
||||
FieldMetadataType.ADDRESS,
|
||||
].includes(fieldMetadata.type);
|
||||
};
|
||||
|
||||
const shouldSkipFieldCreation = (
|
||||
standardFieldMetadata: ComputedPartialFieldMetadata | undefined,
|
||||
) => {
|
||||
@ -55,7 +72,17 @@ export class WorkspaceFieldComparator {
|
||||
const originalFieldMetadataMap = transformMetadataForComparison(
|
||||
filteredOriginalFieldCollection,
|
||||
{
|
||||
shouldIgnoreProperty: (property) => {
|
||||
shouldIgnoreProperty: (
|
||||
property,
|
||||
fieldMetadata: FieldMetadataEntity,
|
||||
) => {
|
||||
if (
|
||||
property === 'defaultValue' &&
|
||||
shouldNotOverrideDefaultValue(fieldMetadata)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (commonFieldPropertiesToIgnore.includes(property)) {
|
||||
return true;
|
||||
}
|
||||
@ -72,7 +99,17 @@ export class WorkspaceFieldComparator {
|
||||
const standardFieldMetadataMap = transformMetadataForComparison(
|
||||
standardFieldMetadataCollection,
|
||||
{
|
||||
shouldIgnoreProperty: (property) => {
|
||||
shouldIgnoreProperty: (
|
||||
property,
|
||||
fieldMetadata: ComputedPartialFieldMetadata,
|
||||
) => {
|
||||
if (
|
||||
property === 'defaultValue' &&
|
||||
shouldNotOverrideDefaultValue(fieldMetadata)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (commonFieldPropertiesToIgnore.includes(property)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user