All files / src/Projection/migrations 1682519108362-stake-pool-table.ts

33.33% Statements 3/9
100% Branches 0/0
0% Functions 0/2
33.33% Lines 3/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  40x   40x 40x                                    
import { MigrationInterface, QueryRunner } from 'typeorm';
import { StakePoolEntity } from '@cardano-sdk/projection-typeorm';
 
export class StakePoolTableMigration1682519108362 implements MigrationInterface {
  static entity = StakePoolEntity;
 
  async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      "CREATE TYPE \"public\".\"stake_pool_status_enum\" AS ENUM('activating', 'active', 'retired', 'retiring')"
    );
    await queryRunner.query(
      'CREATE TABLE "stake_pool" ("id" character(56) NOT NULL, "status" "public"."stake_pool_status_enum" NOT NULL, "last_registration_id" bigint, "last_retirement_id" bigint, CONSTRAINT "REL_stake_pool_last_registration_id" UNIQUE ("last_registration_id"), CONSTRAINT "REL_stake_pool_last_retirement_id" UNIQUE ("last_retirement_id"), CONSTRAINT "PK_stake_pool_id" PRIMARY KEY ("id"))'
    );
    await queryRunner.query('CREATE INDEX "IDX_stake_pool_status" ON "stake_pool" ("status") ');
  }
 
  async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query('DROP INDEX "public"."IDX_stake_pool_status"');
    await queryRunner.query('DROP TABLE "stake_pool"');
    await queryRunner.query('DROP TYPE "public"."stake_pool_status_enum"');
  }
}