Remove old message channel sync statuses and create migration command (#6177)
Remove old message channel sync statuses and create migration command --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,17 +1,17 @@
|
|||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
|
||||||
|
import chalk from 'chalk';
|
||||||
import { Command, CommandRunner, Option } from 'nest-commander';
|
import { Command, CommandRunner, Option } from 'nest-commander';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import chalk from 'chalk';
|
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
|
|
||||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
|
||||||
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
|
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
|
||||||
|
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||||
|
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
|
||||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||||
import { WorkspaceCacheVersionService } from 'src/engine/metadata-modules/workspace-cache-version/workspace-cache-version.service';
|
|
||||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||||
|
import { WorkspaceCacheVersionService } from 'src/engine/metadata-modules/workspace-cache-version/workspace-cache-version.service';
|
||||||
import { MessageChannelSyncStatus } from 'src/modules/messaging/common/standard-objects/message-channel.workspace-entity';
|
import { MessageChannelSyncStatus } from 'src/modules/messaging/common/standard-objects/message-channel.workspace-entity';
|
||||||
|
|
||||||
interface UpdateMessageChannelSyncStatusEnumCommandOptions {
|
interface UpdateMessageChannelSyncStatusEnumCommandOptions {
|
||||||
@ -19,7 +19,7 @@ interface UpdateMessageChannelSyncStatusEnumCommandOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command({
|
@Command({
|
||||||
name: 'migrate-0.20:update-message-channel-sync-status-enum',
|
name: 'migrate-0.22:update-message-channel-sync-status-enum',
|
||||||
description: 'Update messageChannel syncStatus',
|
description: 'Update messageChannel syncStatus',
|
||||||
})
|
})
|
||||||
export class UpdateMessageChannelSyncStatusEnumCommand extends CommandRunner {
|
export class UpdateMessageChannelSyncStatusEnumCommand extends CommandRunner {
|
||||||
@ -94,9 +94,7 @@ export class UpdateMessageChannelSyncStatusEnumCommand extends CommandRunner {
|
|||||||
`ALTER TYPE "${dataSourceMetadata.schema}"."messageChannel_syncStatus_enum" RENAME TO "messageChannel_syncStatus_enum_old"`,
|
`ALTER TYPE "${dataSourceMetadata.schema}"."messageChannel_syncStatus_enum" RENAME TO "messageChannel_syncStatus_enum_old"`,
|
||||||
);
|
);
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`CREATE TYPE "${dataSourceMetadata.schema}"."messageChannel_syncStatus_enum" AS ENUM ('PENDING',
|
`CREATE TYPE "${dataSourceMetadata.schema}"."messageChannel_syncStatus_enum" AS ENUM (
|
||||||
'SUCCEEDED',
|
|
||||||
'FAILED',
|
|
||||||
'ONGOING',
|
'ONGOING',
|
||||||
'NOT_SYNCED',
|
'NOT_SYNCED',
|
||||||
'COMPLETED',
|
'COMPLETED',
|
||||||
@ -166,27 +164,6 @@ export class UpdateMessageChannelSyncStatusEnumCommand extends CommandRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newOptions = [
|
const newOptions = [
|
||||||
{
|
|
||||||
id: v4(),
|
|
||||||
value: MessageChannelSyncStatus.PENDING,
|
|
||||||
label: 'Pending',
|
|
||||||
position: 0,
|
|
||||||
color: 'blue',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: v4(),
|
|
||||||
value: MessageChannelSyncStatus.SUCCEEDED,
|
|
||||||
label: 'Succeeded',
|
|
||||||
position: 2,
|
|
||||||
color: 'green',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: v4(),
|
|
||||||
value: MessageChannelSyncStatus.FAILED,
|
|
||||||
label: 'Failed',
|
|
||||||
position: 3,
|
|
||||||
color: 'red',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: v4(),
|
id: v4(),
|
||||||
value: MessageChannelSyncStatus.ONGOING,
|
value: MessageChannelSyncStatus.ONGOING,
|
||||||
@ -1,8 +1,8 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
|
||||||
import { UpdateMessageChannelSyncStatusEnumCommand } from 'src/database/commands/0-20-update-message-channel-sync-status-enum.command';
|
|
||||||
import { AddNewAddressFieldToViewsWithDeprecatedAddressFieldCommand } from 'src/database/commands/0-22-add-new-address-field-to-views-with-deprecated-address.command';
|
import { AddNewAddressFieldToViewsWithDeprecatedAddressFieldCommand } from 'src/database/commands/0-22-add-new-address-field-to-views-with-deprecated-address.command';
|
||||||
|
import { UpdateMessageChannelSyncStatusEnumCommand } from 'src/database/commands/0-22-update-message-channel-sync-status-enum.command';
|
||||||
import { StartDataSeedDemoWorkspaceCronCommand } from 'src/database/commands/data-seed-demo-workspace/crons/start-data-seed-demo-workspace.cron.command';
|
import { StartDataSeedDemoWorkspaceCronCommand } from 'src/database/commands/data-seed-demo-workspace/crons/start-data-seed-demo-workspace.cron.command';
|
||||||
import { StopDataSeedDemoWorkspaceCronCommand } from 'src/database/commands/data-seed-demo-workspace/crons/stop-data-seed-demo-workspace.cron.command';
|
import { StopDataSeedDemoWorkspaceCronCommand } from 'src/database/commands/data-seed-demo-workspace/crons/stop-data-seed-demo-workspace.cron.command';
|
||||||
import { DataSeedDemoWorkspaceCommand } from 'src/database/commands/data-seed-demo-workspace/data-seed-demo-workspace-command';
|
import { DataSeedDemoWorkspaceCommand } from 'src/database/commands/data-seed-demo-workspace/data-seed-demo-workspace-command';
|
||||||
|
|||||||
@ -5,26 +5,20 @@ import {
|
|||||||
RelationMetadataType,
|
RelationMetadataType,
|
||||||
RelationOnDeleteAction,
|
RelationOnDeleteAction,
|
||||||
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||||
|
import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity';
|
||||||
|
import { WorkspaceEntity } from 'src/engine/twenty-orm/decorators/workspace-entity.decorator';
|
||||||
|
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
|
||||||
|
import { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator';
|
||||||
|
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
|
||||||
|
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
|
||||||
|
import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator';
|
||||||
|
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
|
||||||
import { MESSAGE_CHANNEL_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
import { MESSAGE_CHANNEL_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||||
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
|
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
|
||||||
import { ConnectedAccountWorkspaceEntity } from 'src/modules/connected-account/standard-objects/connected-account.workspace-entity';
|
import { ConnectedAccountWorkspaceEntity } from 'src/modules/connected-account/standard-objects/connected-account.workspace-entity';
|
||||||
import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity';
|
|
||||||
import { WorkspaceEntity } from 'src/engine/twenty-orm/decorators/workspace-entity.decorator';
|
|
||||||
import { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator';
|
|
||||||
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
|
|
||||||
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
|
|
||||||
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
|
|
||||||
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
|
|
||||||
import { MessageChannelMessageAssociationWorkspaceEntity } from 'src/modules/messaging/common/standard-objects/message-channel-message-association.workspace-entity';
|
import { MessageChannelMessageAssociationWorkspaceEntity } from 'src/modules/messaging/common/standard-objects/message-channel-message-association.workspace-entity';
|
||||||
import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator';
|
|
||||||
|
|
||||||
export enum MessageChannelSyncStatus {
|
export enum MessageChannelSyncStatus {
|
||||||
// TO BE DEPRECATED
|
|
||||||
PENDING = 'PENDING',
|
|
||||||
SUCCEEDED = 'SUCCEEDED',
|
|
||||||
FAILED = 'FAILED',
|
|
||||||
|
|
||||||
// NEW STATUSES
|
|
||||||
NOT_SYNCED = 'NOT_SYNCED',
|
NOT_SYNCED = 'NOT_SYNCED',
|
||||||
ONGOING = 'ONGOING',
|
ONGOING = 'ONGOING',
|
||||||
COMPLETED = 'COMPLETED',
|
COMPLETED = 'COMPLETED',
|
||||||
@ -230,26 +224,6 @@ export class MessageChannelWorkspaceEntity extends BaseWorkspaceEntity {
|
|||||||
description: 'Sync status',
|
description: 'Sync status',
|
||||||
icon: 'IconStatusChange',
|
icon: 'IconStatusChange',
|
||||||
options: [
|
options: [
|
||||||
// TO BE DEPRECATED: PENDING, SUCCEEDED, FAILED
|
|
||||||
{
|
|
||||||
value: MessageChannelSyncStatus.PENDING,
|
|
||||||
label: 'Pending',
|
|
||||||
position: 0,
|
|
||||||
color: 'blue',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: MessageChannelSyncStatus.SUCCEEDED,
|
|
||||||
label: 'Succeeded',
|
|
||||||
position: 2,
|
|
||||||
color: 'green',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: MessageChannelSyncStatus.FAILED,
|
|
||||||
label: 'Failed',
|
|
||||||
position: 3,
|
|
||||||
color: 'red',
|
|
||||||
},
|
|
||||||
// NEW STATUSES
|
|
||||||
{
|
{
|
||||||
value: MessageChannelSyncStatus.ONGOING,
|
value: MessageChannelSyncStatus.ONGOING,
|
||||||
label: 'Ongoing',
|
label: 'Ongoing',
|
||||||
|
|||||||
Reference in New Issue
Block a user