Skip to content

Commit

Permalink
Merge pull request #234 from d-rec/DR-797
Browse files Browse the repository at this point in the history
DR-797 Migration file for old issuer certificates
  • Loading branch information
Aish1990 authored May 15, 2024
2 parents 1d82b63 + 8ca851d commit 0f1de12
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
29 changes: 29 additions & 0 deletions apps/drec-api/migrations/1715146626520-OldIssuerLog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class OldIssuerLog1715146626520 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
//IMPORTANT NOTE: We have generated this entity to have a backup of our old certificate logs
//generated before upgraded the @energyweb/issuer-api... because the old certificate logs are
//not compatible with newly upgraded issuer-certificates struture..
await queryRunner.query(`
CREATE TABLE old_issuer_certificate (
"createdAt" timestamp with time zone NOT NULL DEFAULT now(),
"updatedAt" timestamp with time zone NOT NULL DEFAULT now(),
"id" SERIAL NOT NULL,
"deviceId" character varying NOT NULL,
"generationStartTime" integer NOT NULL,
"generationEndTime" integer NOT NULL,
"creationTime" integer NOT NULL,
"creationBlockHash" character varying,
"owners" text NOT NULL,
"claimers" text,
"claims" text,
"latestCommitment" text,
"issuedPrivately" boolean NOT NULL,
"blockchainNetId" integer,
"metadata" character varying NOT NULL,
)`);
}

public async down(queryRunner: QueryRunner): Promise<void> {}
}
12 changes: 8 additions & 4 deletions apps/drec-api/migrations/9999999999999-Seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,17 @@ export class Seed9999999999999 implements MigrationInterface {

if (provider && contractsLookup) {
await queryRunner.query(
`INSERT INTO public.issuer_blockchain_properties ("netId", "registry", "issuer", "rpcNode", "rpcNodeFallback", "platformOperatorPrivateKey") VALUES (${
`INSERT INTO public.issuer_blockchain_properties ("netId", "registry", "issuer", "rpcNode", "rpcNodeFallback") VALUES (${
provider.network.chainId
}, '${contractsLookup.registry}', '${
contractsLookup.issuer
}', '${primaryRpc}', '${fallbackRpc ?? ''}', '${
issuerAccount.privateKey
}')`,
}', '${primaryRpc}', '${fallbackRpc ?? ''}'
)`,
);

await queryRunner.query(
`INSERT INTO public.issuer_signer ("blockchainNetId", "platformOperatorPrivateKey", "isEncrypted") VALUES (${provider.network.chainId}, '${issuerAccount.privateKey}', false
)`,
);
}

Expand Down

0 comments on commit 0f1de12

Please sign in to comment.