All files / src/Projection/migrations 1689091319930-cost-pledge-numeric.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 CostPledgeNumericMigration1689091319930 implements MigrationInterface {
  static entity = PoolRegistrationEntity;
 
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      'ALTER TABLE "pool_registration" ALTER COLUMN "pledge" TYPE numeric(20,0) USING pledge::numeric'
    );
    await queryRunner.query(
      'ALTER TABLE "pool_registration" ALTER COLUMN "cost" TYPE numeric(20,0) USING cost::numeric'
    );
  }
 
  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query('ALTER TABLE "pool_registration" ALTER COLUMN "cost" TYPE bigint USING cost::bigint');
    await queryRunner.query('ALTER TABLE "pool_registration" ALTER COLUMN "pledge" TYPE bigint USING pledge::bigint');
  }
}