All files / src/Projection/migrations 1698174358997-current-pool-metrics-attributes.ts

11.11% Statements 3/27
100% Branches 0/0
0% Functions 0/2
11.11% Lines 3/27

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 24 25 26 27 28 29 30 31 32 33 34 35 36 3740x     40x 40x                                                                
import { CurrentPoolMetricsEntity } from '@cardano-sdk/projection-typeorm';
import { MigrationInterface, QueryRunner } from 'typeorm';
 
export class CurrentStakePollMetricsAttributesMigrations1698174358997 implements MigrationInterface {
  static entity = CurrentPoolMetricsEntity;
 
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query('ALTER TABLE "current_pool_metrics" DROP COLUMN "apy"');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ADD "last_ros" numeric');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ADD "ros" numeric');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "slot" DROP NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "minted_blocks" DROP NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "live_delegators" DROP NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "active_stake" DROP NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "live_stake" DROP NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "live_pledge" DROP NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "live_saturation" DROP NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "active_size" DROP NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "live_size" DROP NOT NULL');
  }
 
  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "live_size" SET NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "active_size" SET NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "live_saturation" SET NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "live_pledge" SET NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "live_stake" SET NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "active_stake" SET NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "live_delegators" SET NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "minted_blocks" SET NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ALTER COLUMN "slot" SET NOT NULL');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" DROP COLUMN "ros"');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" DROP COLUMN "last_ros"');
    await queryRunner.query('ALTER TABLE "current_pool_metrics" ADD "apy" numeric NOT NULL');
  }
}