From f0ae0ec33536f895fd4544bb3995da72599b7850 Mon Sep 17 00:00:00 2001 From: yulia-bel Date: Mon, 18 Sep 2023 14:47:41 +0200 Subject: [PATCH] Add migration file to update clone_piece_enum to include 'project-cost-surfaces' --- ...835-AddClonePieceForProjectCostSurfaces.ts | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 api/apps/api/src/migrations/api/1695040870835-AddClonePieceForProjectCostSurfaces.ts diff --git a/api/apps/api/src/migrations/api/1695040870835-AddClonePieceForProjectCostSurfaces.ts b/api/apps/api/src/migrations/api/1695040870835-AddClonePieceForProjectCostSurfaces.ts new file mode 100644 index 0000000000..5eec1a2665 --- /dev/null +++ b/api/apps/api/src/migrations/api/1695040870835-AddClonePieceForProjectCostSurfaces.ts @@ -0,0 +1,53 @@ +import { MigrationInterface, QueryRunner } from "typeorm" + +export class AddClonePieceForProjectCostSurfaces1695040870835 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TYPE clone_piece_enum ADD VALUE 'project-cost-surfaces'`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + CREATE TYPE "clone_piece_enum_tmp" AS ENUM( + 'export-config', + 'project-metadata', + 'project-custom-protected-areas', + 'planning-area-gadm', + 'planning-area-custom', + 'planning-area-custom-geojson', + 'planning-units-grid', + 'planning-units-grid-geojson', + 'scenario-metadata', + 'scenario-planning-units-data', + 'scenario-run-results', + 'scenario-protected-areas', + 'project-custom-features', + 'features-specification', + 'scenario-features-data', + 'scenario-input-folder', + 'scenario-output-folder', + 'marxan-execution-metadata', + 'project-puvspr-calculations' + ); + `); + + await queryRunner.query(` + ALTER TABLE export_components + ALTER COLUMN piece TYPE clone_piece_enum_tmp; + `); + await queryRunner.query(` + ALTER TABLE import_components + ALTER COLUMN piece TYPE clone_piece_enum_tmp; + `); + + await queryRunner.query(` + DROP TYPE clone_piece_enum; + `); + await queryRunner.query(` + ALTER TYPE clone_piece_enum_tmp RENAME TO clone_piece_enum; + `); + } + +}