Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/email-marketing/entities/automation-action.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
JoinColumn,
DeleteDateColumn,
VersionColumn,
Index,
} from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { AutomationWorkflow } from './automation-workflow.entity';
Expand All @@ -15,6 +16,8 @@ import { ActionType } from '../enums/action-type.enum';
* Represents the automation Action entity.
*/
@Entity('automation_actions')
@Index('IDX_automation_actions_workflowId_order', ['workflowId', 'order'])
@Index('IDX_automation_actions_workflowId_type', ['workflowId', 'type'])
export class AutomationAction {
@ApiProperty()
@PrimaryGeneratedColumn('uuid')
Expand All @@ -24,6 +27,7 @@ export class AutomationAction {
version: number;

@ApiProperty()
@Index('IDX_automation_actions_workflowId')
@Column()
workflowId: string;

Expand All @@ -32,6 +36,7 @@ export class AutomationAction {
workflow: AutomationWorkflow;

@ApiProperty({ enum: ActionType })
@Index('IDX_automation_actions_type')
@Column({ type: 'enum', enum: ActionType })
type: ActionType;

Expand All @@ -40,13 +45,15 @@ export class AutomationAction {
config: Record<string, any>;

@ApiProperty()
@Index('IDX_automation_actions_order')
@Column({ default: 0 })
order: number;

@ApiProperty({ required: false })
@Column({ type: 'text', nullable: true })
description?: string;

@Index('IDX_automation_actions_deletedAt')
@DeleteDateColumn()
deletedAt?: Date;
}
33 changes: 33 additions & 0 deletions src/migrations/1800000000001-add-automation-action-indexes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddAutomationActionIndexes1800000000001 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'CREATE INDEX IF NOT EXISTS "IDX_automation_actions_workflowId" ON "automation_actions" ("workflowId")',
);
await queryRunner.query(
'CREATE INDEX IF NOT EXISTS "IDX_automation_actions_type" ON "automation_actions" ("type")',
);
await queryRunner.query(
'CREATE INDEX IF NOT EXISTS "IDX_automation_actions_order" ON "automation_actions" ("order")',
);
await queryRunner.query(
'CREATE INDEX IF NOT EXISTS "IDX_automation_actions_deletedAt" ON "automation_actions" ("deletedAt")',
);
await queryRunner.query(
'CREATE INDEX IF NOT EXISTS "IDX_automation_actions_workflowId_order" ON "automation_actions" ("workflowId", "order")',
);
await queryRunner.query(
'CREATE INDEX IF NOT EXISTS "IDX_automation_actions_workflowId_type" ON "automation_actions" ("workflowId", "type")',
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('DROP INDEX IF EXISTS "IDX_automation_actions_workflowId_type"');
await queryRunner.query('DROP INDEX IF EXISTS "IDX_automation_actions_workflowId_order"');
await queryRunner.query('DROP INDEX IF EXISTS "IDX_automation_actions_deletedAt"');
await queryRunner.query('DROP INDEX IF EXISTS "IDX_automation_actions_order"');
await queryRunner.query('DROP INDEX IF EXISTS "IDX_automation_actions_type"');
await queryRunner.query('DROP INDEX IF EXISTS "IDX_automation_actions_workflowId"');
}
}
Loading