From 04b8d100879dfa65073c831033aa1de727093762 Mon Sep 17 00:00:00 2001 From: Derrick Persson Date: Mon, 25 Nov 2024 10:17:07 -0800 Subject: [PATCH] Adding migration to handle suggested / discovered rules (#757) --- src/modules/frameworks/rule.entity.ts | 3 +++ .../migrations/1731965342331-addIsDraftToRule.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/shared/database/migrations/1731965342331-addIsDraftToRule.ts diff --git a/src/modules/frameworks/rule.entity.ts b/src/modules/frameworks/rule.entity.ts index 822ea63b..1c86a32c 100644 --- a/src/modules/frameworks/rule.entity.ts +++ b/src/modules/frameworks/rule.entity.ts @@ -41,6 +41,9 @@ export class Rule extends PublicEntity { @Column("integer", { name: "organization_id", nullable: true }) organization_id?: number; + @Column("boolean", { name: "is_draft", default: false }) + isDraft!: boolean; + @ManyToOne(() => Organization, { nullable: true, }) @JoinColumn({ name: "organization_id" }) organization?: Organization; diff --git a/src/shared/database/migrations/1731965342331-addIsDraftToRule.ts b/src/shared/database/migrations/1731965342331-addIsDraftToRule.ts new file mode 100644 index 00000000..09b6abbf --- /dev/null +++ b/src/shared/database/migrations/1731965342331-addIsDraftToRule.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddIsDraftToRule1731965342331 implements MigrationInterface { + name = "AddIsDraftToRule1731965342331" + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "rules" ADD "is_draft" boolean NOT NULL DEFAULT false`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "rules" DROP COLUMN "is_draft"`); + } + +}