Skip to content

Commit

Permalink
Added dev branch remaining migration changes (#983)
Browse files Browse the repository at this point in the history
Co-authored-by: RidhamShah <[email protected]>
  • Loading branch information
RidhamShah and RidhamShah authored Aug 24, 2023
1 parent 9a79b8e commit 98ae618
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class remainingDevMigrations1692792001871 implements MigrationInterface {
name = 'remainingDevMigrations1692792001871';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TYPE "public"."query_repeatedmeasure_enum" RENAME TO "query_repeatedmeasure_enum_old"`
);
await queryRunner.query(
`CREATE TYPE "public"."query_repeatedmeasure_enum" AS ENUM('MEAN', 'EARLIEST', 'MOST RECENT', 'COUNT', 'PERCENTAGE')`
);
await queryRunner.query(`ALTER TABLE "public"."query" ALTER COLUMN "repeatedMeasure" DROP DEFAULT`);
await queryRunner.query(
`ALTER TABLE "public"."query" ALTER COLUMN "repeatedMeasure" TYPE "public"."query_repeatedmeasure_enum" USING "repeatedMeasure"::"text"::"public"."query_repeatedmeasure_enum"`
);
await queryRunner.query(`ALTER TABLE "public"."query" ALTER COLUMN "repeatedMeasure" SET DEFAULT 'MOST RECENT'`);
await queryRunner.query(`DROP TYPE "public"."query_repeatedmeasure_enum_old"`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TYPE "public"."query_repeatedmeasure_enum_old" AS ENUM('EARLIEST', 'MEAN', 'MOST RECENT')`
);
await queryRunner.query(`ALTER TABLE "public"."query" ALTER COLUMN "repeatedMeasure" DROP DEFAULT`);
await queryRunner.query(
`ALTER TABLE "public"."query" ALTER COLUMN "repeatedMeasure" TYPE "public"."query_repeatedmeasure_enum_old" USING "repeatedMeasure"::"text"::"public"."query_repeatedmeasure_enum_old"`
);
await queryRunner.query(`ALTER TABLE "public"."query" ALTER COLUMN "repeatedMeasure" SET DEFAULT 'MOST RECENT'`);
await queryRunner.query(`DROP TYPE "public"."query_repeatedmeasure_enum"`);
await queryRunner.query(
`ALTER TYPE "public"."query_repeatedmeasure_enum_old" RENAME TO "query_repeatedmeasure_enum"`
);
}
}

0 comments on commit 98ae618

Please sign in to comment.