Skip to content

Commit

Permalink
Merge pull request #52 from logion-network/hotfix/metadata-value
Browse files Browse the repository at this point in the history
feat: set metadata value text.
  • Loading branch information
gdethier authored Nov 25, 2021
2 parents e0a8ce0 + 8a715f7 commit d3ea9e6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/logion/migration/1637834996469-MakeMetadataValueText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class MakeMetadataValueText1637834996469 implements MigrationInterface {
name = 'MakeMetadataValueText1637834996469'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "public"."loc_metadata_item" ADD "value_text" text NOT NULL DEFAULT ''`);
await queryRunner.query(`ALTER TABLE "public"."loc_metadata_item" ALTER COLUMN "value" DROP NOT NULL`);
await queryRunner.query(`UPDATE "public"."loc_metadata_item" SET "value_text" = "value"`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "public"."loc_metadata_item" ALTER COLUMN "value" SET NOT NULL`);
await queryRunner.query(`ALTER TABLE "public"."loc_metadata_item" DROP COLUMN "value_text"`);
}

}
5 changes: 4 additions & 1 deletion src/logion/model/locrequest.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ export class LocMetadataItem extends Child {
@Column({ length: 255 })
name?: string;

@Column({ length: 255 })
@Column({ name: "value", length: 255, nullable: true})
deprecated_value?: string;

@Column("text", { name: "value_text", default: "" })
value?: string;

@ManyToOne(() => LocRequestAggregateRoot, request => request.metadata)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/model/loc_requests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ INSERT INTO loc_request (id, owner_address, requester_address, description, stat
VALUES ('2b287596-f9d5-8030-b606-d1da538cb37f', '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', '5CXLTF2PFBE89tTYsrofGPkSfGTdmW4ciw4vAfgcKhjggRgZ', 'loc-10', 'OPEN', 'Transaction');
INSERT INTO loc_request_file (request_id, hash, name, oid, content_type, added_on, "index", draft)
VALUES ('2b287596-f9d5-8030-b606-d1da538cb37f', '0x1307990e6ba5ca145eb35e99182a9bec46531bc54ddf656a602c780fa0240dee', 'a file', 123456, 'text/plain', '2021-10-06T11:16:00.000', 0, TRUE);
INSERT INTO loc_metadata_item (request_id, "index", name, "value", added_on)
INSERT INTO loc_metadata_item (request_id, "index", name, "value_text", added_on)
VALUES ('2b287596-f9d5-8030-b606-d1da538cb37f', 0, 'a name', 'a value', '2021-10-06T11:16:00.000');
INSERT INTO loc_link (request_id, "index", target, added_on)
VALUES ('2b287596-f9d5-8030-b606-d1da538cb37f', 0, 'ec126c6c-64cf-4eb8-bfa6-2a98cd19ad5d', '2021-10-06T11:16:00.000')

0 comments on commit d3ea9e6

Please sign in to comment.