@@ -4,6 +4,30 @@ export class RemoveContentModeration1774453578372 implements MigrationInterface
44 name = 'RemoveContentModeration1774453578372' ;
55
66 public async up ( queryRunner : QueryRunner ) : Promise < void > {
7+ await queryRunner . query ( `
8+ UPDATE "hmt"."jobs"
9+ SET "status" = 'paid'
10+ WHERE "status" IN ('moderation_passed', 'under_moderation')
11+ ` ) ;
12+ await queryRunner . query ( `
13+ UPDATE "hmt"."jobs"
14+ SET "status" = 'failed'
15+ WHERE "status" = 'possible_abuse_in_review'
16+ ` ) ;
17+ await queryRunner . query ( `
18+ DELETE FROM "hmt"."cron-jobs"
19+ WHERE "cron_job_type" = 'content-moderation'
20+ ` ) ;
21+ await queryRunner . query ( `
22+ ALTER TABLE "hmt"."content-moderation-requests"
23+ DROP CONSTRAINT IF EXISTS "FK_d4f313caf54945a83b00abc02af"
24+ ` ) ;
25+ await queryRunner . query ( `
26+ DROP TABLE IF EXISTS "hmt"."content-moderation-requests"
27+ ` ) ;
28+ await queryRunner . query ( `
29+ DROP TYPE IF EXISTS "hmt"."content-moderation-requests_status_enum"
30+ ` ) ;
731 await queryRunner . query ( `
832 ALTER TYPE "hmt"."jobs_status_enum"
933 RENAME TO "jobs_status_enum_old"
@@ -50,6 +74,28 @@ export class RemoveContentModeration1774453578372 implements MigrationInterface
5074 }
5175
5276 public async down ( queryRunner : QueryRunner ) : Promise < void > {
77+ await queryRunner . query ( `
78+ CREATE TYPE "hmt"."content-moderation-requests_status_enum" AS ENUM(
79+ 'pending',
80+ 'processed',
81+ 'positive_abuse',
82+ 'passed',
83+ 'failed'
84+ )
85+ ` ) ;
86+ await queryRunner . query ( `
87+ CREATE TABLE "hmt"."content-moderation-requests" (
88+ "id" SERIAL NOT NULL,
89+ "created_at" TIMESTAMP WITH TIME ZONE NOT NULL,
90+ "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL,
91+ "data_url" character varying NOT NULL,
92+ "from" integer NOT NULL,
93+ "to" integer NOT NULL,
94+ "status" "hmt"."content-moderation-requests_status_enum" NOT NULL,
95+ "job_id" integer NOT NULL,
96+ CONSTRAINT "PK_e81154211cbfb9f8dcd56158313" PRIMARY KEY ("id")
97+ )
98+ ` ) ;
5399 await queryRunner . query ( `
54100 CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum_old" AS ENUM(
55101 'abuse',
@@ -97,5 +143,9 @@ export class RemoveContentModeration1774453578372 implements MigrationInterface
97143 ALTER TYPE "hmt"."jobs_status_enum_old"
98144 RENAME TO "jobs_status_enum"
99145 ` ) ;
146+ await queryRunner . query ( `
147+ ALTER TABLE "hmt"."content-moderation-requests"
148+ ADD CONSTRAINT "FK_d4f313caf54945a83b00abc02af" FOREIGN KEY ("job_id") REFERENCES "hmt"."jobs"("id") ON DELETE NO ACTION ON UPDATE NO ACTION
149+ ` ) ;
100150 }
101151}
0 commit comments