-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration file to update clone_piece_enum to include 'project-cos…
…t-surfaces'
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
api/apps/api/src/migrations/api/1695040870835-AddClonePieceForProjectCostSurfaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
|
||
export class AddClonePieceForProjectCostSurfaces1695040870835 implements MigrationInterface { | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TYPE clone_piece_enum ADD VALUE 'project-cost-surfaces'`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
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; | ||
`); | ||
} | ||
|
||
} |