All files / src/Projection/migrations 1682519108365-asset-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 2140x     40x 40x     2x     2x                    
import { AssetEntity } from '@cardano-sdk/projection-typeorm';
import { MigrationInterface, QueryRunner } from 'typeorm';
 
export class AssetTableMigration1682519108365 implements MigrationInterface {
  static entity = AssetEntity;
 
  async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      'CREATE TABLE "asset" ("id" character varying NOT NULL, "supply" numeric NOT NULL, "first_mint_block_slot" integer NOT NULL, CONSTRAINT "PK_asset_id" PRIMARY KEY ("id"))'
    );
    await queryRunner.query(
      'ALTER TABLE "asset" ADD CONSTRAINT "FK_asset_first_mint_block_slot" FOREIGN KEY ("first_mint_block_slot") REFERENCES "block"("slot") ON DELETE CASCADE ON UPDATE NO ACTION'
    );
  }
 
  async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query('ALTER TABLE "asset" DROP CONSTRAINT "FK_asset_first_mint_block_slot"');
    await queryRunner.query('DROP TABLE "asset"');
  }
}