All files / src/Projection/migrations 1682519108360-pool-registration-table.ts

42.85% Statements 3/7
100% Branches 0/0
0% Functions 0/2
42.85% Lines 3/7

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  35x   35x 35x                                
import { MigrationInterface, QueryRunner } from 'typeorm';
import { PoolRegistrationEntity } from '@cardano-sdk/projection-typeorm';
 
export class PoolRegistrationTableMigration1682519108360 implements MigrationInterface {
  static entity = PoolRegistrationEntity;
 
  async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      'CREATE TABLE "pool_registration" ("id" bigint NOT NULL, "reward_account" character varying NOT NULL, "pledge" bigint NOT NULL, "cost" bigint NOT NULL, "margin" jsonb NOT NULL, "margin_percent" real NOT NULL, "relays" jsonb NOT NULL, "owners" jsonb NOT NULL, "vrf" character(64) NOT NULL, "metadata_url" character varying, "metadata_hash" character(64), "stake_pool_id" character(56) NOT NULL, "block_slot" integer NOT NULL, CONSTRAINT "PK_pool_registration_id" PRIMARY KEY ("id"))'
    );
    await queryRunner.query(
      'ALTER TABLE "pool_registration" ADD CONSTRAINT "FK_pool_registration_block_slot" FOREIGN KEY ("block_slot") REFERENCES "block"("slot") ON DELETE CASCADE ON UPDATE NO ACTION'
    );
  }
 
  async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query('ALTER TABLE "pool_registration" DROP CONSTRAINT "FK_pool_registration_block_slot"');
    await queryRunner.query('DROP TABLE "pool_registration"');
  }
}