All files / src/Projection/migrations 1682519108358-block-table.ts

66.66% Statements 6/9
100% Branches 0/0
50% Functions 1/2
66.66% Lines 6/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 2140x     40x 40x     2x     2x 2x                  
import { BlockEntity } from '@cardano-sdk/projection-typeorm';
import { MigrationInterface, QueryRunner } from 'typeorm';
 
export class BlockTableMigration1682519108358 implements MigrationInterface {
  static entity = BlockEntity;
 
  async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      'CREATE TABLE "block" ("height" integer NOT NULL, "hash" character(64) NOT NULL, "slot" integer NOT NULL, CONSTRAINT "PK_block_slot" PRIMARY KEY ("slot"))'
    );
    await queryRunner.query('CREATE UNIQUE INDEX "IDX_block_height" ON "block" ("height") ');
    await queryRunner.query('CREATE UNIQUE INDEX "IDX_block_hash" ON "block" ("hash") ');
  }
 
  async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query('DROP INDEX "public"."IDX_block_hash"');
    await queryRunner.query('DROP INDEX "public"."IDX_block_height"');
    await queryRunner.query('DROP TABLE "block"');
  }
}