All files / src/Projection/migrations 1682519108359-block-data-table.ts

71.42% Statements 5/7
100% Branches 0/0
50% Functions 1/2
71.42% Lines 5/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 2135x     35x 35x     2x     2x                    
import { BlockDataEntity } from '@cardano-sdk/projection-typeorm';
import { MigrationInterface, QueryRunner } from 'typeorm';
 
export class BlockDataTableMigration1682519108359 implements MigrationInterface {
  static entity = BlockDataEntity;
 
  async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      'CREATE TABLE "block_data" ("block_height" integer NOT NULL, "data" bytea NOT NULL, CONSTRAINT "PK_block_data_block_height" PRIMARY KEY ("block_height"))'
    );
    await queryRunner.query(
      'ALTER TABLE "block_data" ADD CONSTRAINT "FK_block_data_block_height" FOREIGN KEY ("block_height") REFERENCES "block"("height") ON DELETE CASCADE ON UPDATE NO ACTION'
    );
  }
 
  async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query('ALTER TABLE "block_data" DROP CONSTRAINT "FK_block_data_block_height"');
    await queryRunner.query('DROP TABLE "block_data"');
  }
}