From 38318ae7a47e578c874d54495b6d75ebb03224e1 Mon Sep 17 00:00:00 2001 From: John Melati Date: Wed, 10 Apr 2024 14:35:25 +0200 Subject: [PATCH] fix: set uri to nullable in Party table --- .../postgres/1659463079428-CreateContacts.ts | 19 ------------------ .../postgres/1690925872592-CreateContacts.ts | 20 ++++++++++++++++++- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/packages/data-store/src/migrations/postgres/1659463079428-CreateContacts.ts b/packages/data-store/src/migrations/postgres/1659463079428-CreateContacts.ts index 5868c1483..4016ee730 100644 --- a/packages/data-store/src/migrations/postgres/1659463079428-CreateContacts.ts +++ b/packages/data-store/src/migrations/postgres/1659463079428-CreateContacts.ts @@ -42,24 +42,6 @@ export class CreateContacts1659463079428 implements MigrationInterface { await queryRunner.query( `ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, ) - - await queryRunner.query(` - CREATE TABLE "PhysicalAddress" ( - "id" text PRIMARY KEY NOT NULL, - "type" varchar(255) NOT NULL, - "street_name" varchar(255) NOT NULL, - "street_number" varchar(255) NOT NULL, - "postal_code" varchar(255) NOT NULL, - "city_name" varchar(255) NOT NULL, - "province_name" varchar(255) NOT NULL, - "country_code" varchar(2) NOT NULL, - "building_name" varchar(255), - "partyId" uuid, - "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - "last_updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - CONSTRAINT "FK_PhysicalAddressEntity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE - );` - ); } public async down(queryRunner: QueryRunner): Promise { @@ -77,6 +59,5 @@ export class CreateContacts1659463079428 implements MigrationInterface { await queryRunner.query(`DROP TYPE "public"."CorrelationIdentifier_type_enum"`) await queryRunner.query(`DROP INDEX "public"."IDX_BaseConfigEntity_type"`) await queryRunner.query(`DROP TABLE "BaseConfigEntity"`) - await queryRunner.query(`DROP TABLE "PhysicalAddress"`) } } diff --git a/packages/data-store/src/migrations/postgres/1690925872592-CreateContacts.ts b/packages/data-store/src/migrations/postgres/1690925872592-CreateContacts.ts index de8330c50..0bfb18706 100644 --- a/packages/data-store/src/migrations/postgres/1690925872592-CreateContacts.ts +++ b/packages/data-store/src/migrations/postgres/1690925872592-CreateContacts.ts @@ -29,7 +29,7 @@ export class CreateContacts1690925872592 implements MigrationInterface { `CREATE TABLE "ElectronicAddress" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" character varying(255) NOT NULL, "electronic_address" character varying(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "partyId" uuid, CONSTRAINT "PK_ElectronicAddress_id" PRIMARY KEY ("id"))`, ) await queryRunner.query( - `CREATE TABLE "Party" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "party_type_id" uuid NOT NULL, CONSTRAINT "PK_Party_id" PRIMARY KEY ("id"))`, + `CREATE TABLE "Party" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "uri" character varying(255), "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "party_type_id" uuid NOT NULL, CONSTRAINT "PK_Party_id" PRIMARY KEY ("id"))`, ) await queryRunner.query( `CREATE TABLE "BaseConfig" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "identifier" character varying(255), "redirect_url" character varying(255), "session_id" character varying(255), "client_id" character varying(255), "client_secret" character varying(255), "scopes" text, "issuer" character varying(255), "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "type" character varying NOT NULL, "connection_id" uuid, CONSTRAINT "REL_BaseConfig_connection_id" UNIQUE ("connection_id"), CONSTRAINT "PK_BaseConfig_id" PRIMARY KEY ("id"))`, @@ -85,6 +85,24 @@ export class CreateContacts1690925872592 implements MigrationInterface { `INSERT INTO "BaseContact"(id, legal_name, display_name, party_id, created_at, last_updated_at, type) SELECT id, name, alias, id, created_at, last_updated_at, 'Organization' FROM "Contact"`, ) await queryRunner.query(`DROP TABLE "Contact"`) + + await queryRunner.query(` + CREATE TABLE "PhysicalAddress" ( + "id" text PRIMARY KEY NOT NULL, + "type" varchar(255) NOT NULL, + "street_name" varchar(255) NOT NULL, + "street_number" varchar(255) NOT NULL, + "postal_code" varchar(255) NOT NULL, + "city_name" varchar(255) NOT NULL, + "province_name" varchar(255) NOT NULL, + "country_code" varchar(2) NOT NULL, + "building_name" varchar(255), + "partyId" uuid, + "created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + "last_updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT "FK_PhysicalAddressEntity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE + );` + ); } public async down(queryRunner: QueryRunner): Promise {