All files / src/Projection/migrations 1724168174191-governance-actions-table.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 2135x     35x 35x                                
import { GovernanceActionEntity } from '@cardano-sdk/projection-typeorm';
import { MigrationInterface, QueryRunner } from 'typeorm';
 
export class GovernanceActionMigration1724168174191 implements MigrationInterface {
  static entity = GovernanceActionEntity;
 
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      'CREATE TABLE "governance_action" ("id" SERIAL NOT NULL, "tx_id" character varying NOT NULL, "index" smallint NOT NULL, "stake_credential_hash" character varying NOT NULL, "anchor_url" character varying NOT NULL, "anchor_hash" character(64), "deposit" bigint NOT NULL, "action" character varying NOT NULL, "block_slot" integer NOT NULL, CONSTRAINT "PK_governance_action_id" PRIMARY KEY ("id"))'
    );
    await queryRunner.query(
      'ALTER TABLE "governance_action" ADD CONSTRAINT "FK_governance_action_block_slot" FOREIGN KEY ("block_slot") REFERENCES "block"("slot") ON DELETE CASCADE ON UPDATE NO ACTION'
    );
  }
 
  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query('ALTER TABLE "governance_action" DROP CONSTRAINT "FK_governance_action_block_slot"');
    await queryRunner.query('DROP TABLE "governance_action"');
  }
}