From fac4fa3fb6898ac82c77b650587dbaca14ad82f2 Mon Sep 17 00:00:00 2001 From: luekromanowicz Date: Wed, 4 Oct 2023 10:43:49 +0200 Subject: [PATCH] add migration --- .../1696408787963-SubmissionVerification.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 apps/scv-gateway/src/database/migrations/1696408787963-SubmissionVerification.ts diff --git a/apps/scv-gateway/src/database/migrations/1696408787963-SubmissionVerification.ts b/apps/scv-gateway/src/database/migrations/1696408787963-SubmissionVerification.ts new file mode 100644 index 0000000..19f98ab --- /dev/null +++ b/apps/scv-gateway/src/database/migrations/1696408787963-SubmissionVerification.ts @@ -0,0 +1,47 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class SubmissionVerification1696408787963 implements MigrationInterface { + name = 'SubmissionVerification1696408787963'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "contract_submissions" ADD "submitted_at" TIMESTAMP NOT NULL DEFAULT now()`, + ); + await queryRunner.query( + `CREATE TYPE "public"."contract_submissions_status_enum" AS ENUM('pending', 'success', 'fail')`, + ); + await queryRunner.query( + `ALTER TABLE "contract_submissions" ADD "status" "public"."contract_submissions_status_enum" NOT NULL DEFAULT 'pending'`, + ); + await queryRunner.query( + `ALTER TABLE "contract_submissions" ADD "result" character varying`, + ); + await queryRunner.query( + `ALTER TABLE "contract_source_files" DROP COLUMN "file_path"`, + ); + await queryRunner.query( + `ALTER TABLE "contract_source_files" ADD "file_path" character varying NOT NULL`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "contract_source_files" DROP COLUMN "file_path"`, + ); + await queryRunner.query( + `ALTER TABLE "contract_source_files" ADD "file_path" character varying(127) NOT NULL`, + ); + await queryRunner.query( + `ALTER TABLE "contract_submissions" DROP COLUMN "result"`, + ); + await queryRunner.query( + `ALTER TABLE "contract_submissions" DROP COLUMN "status"`, + ); + await queryRunner.query( + `DROP TYPE "public"."contract_submissions_status_enum"`, + ); + await queryRunner.query( + `ALTER TABLE "contract_submissions" DROP COLUMN "submitted_at"`, + ); + } +}