From deb73c7293512da85ed33608e54178b952913df9 Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Mon, 4 Sep 2023 14:35:49 +0200 Subject: [PATCH] DPP-1 postgres migration WIP --- packages/data-store/src/__tests__/contact.entities.test.ts | 2 +- .../src/migrations/postgres/1690925872592-CreateContacts.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/data-store/src/__tests__/contact.entities.test.ts b/packages/data-store/src/__tests__/contact.entities.test.ts index fb9ab380b..f68998a5b 100644 --- a/packages/data-store/src/__tests__/contact.entities.test.ts +++ b/packages/data-store/src/__tests__/contact.entities.test.ts @@ -105,7 +105,7 @@ describe('Database entities tests', (): void => { port: 5432, // Default PostgreSQL port username: 'postgres', password: 'btencate', - database: 'contacts3-ssi-sdk', + database: 'contacts4-ssi-sdk', migrationsRun: false, migrations: DataStoreMigrations, diff --git a/packages/data-store/src/migrations/postgres/1690925872592-CreateContacts.ts b/packages/data-store/src/migrations/postgres/1690925872592-CreateContacts.ts index 0ab73368d..729e6395e 100644 --- a/packages/data-store/src/migrations/postgres/1690925872592-CreateContacts.ts +++ b/packages/data-store/src/migrations/postgres/1690925872592-CreateContacts.ts @@ -38,7 +38,11 @@ export class CreateContacts1690925872592 implements MigrationInterface { await queryRunner.query(`ALTER TABLE "BaseConfig" ADD CONSTRAINT "FK_4b10e0398e0bc003b479a21f53e" FOREIGN KEY ("connection_id") REFERENCES "Connection"("id") ON DELETE CASCADE ON UPDATE NO ACTION`) + await queryRunner.query(`INSERT INTO "BaseConfig"("id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id") SELECT "id", "identifier", "redirect_url", "session_id", "client_id", "client_secret", "scopes", "issuer", "dangerously_allow_insecure_http_requests", "client_auth_method", "type", "connection_id" FROM "BaseConfigEntity"`) await queryRunner.query(`DROP TABLE "BaseConfigEntity"`) + await queryRunner.query(`INSERT INTO "PartyType"(id, type, name, description, tenant_id, created_at, last_updated_at) VALUES ('3875c12e-fdaa-4ef6-a340-c936e054b627', 'organization', 'Sphereon_default_type', 'sphereon_default_organization', '95e09cfc-c974-4174-86aa-7bf1d5251fb4', now(), now())`) + await queryRunner.query(`INSERT INTO "Party"(id, uri, created_at, last_updated_at, party_type_id) SELECT id, uri, created_at, last_updated_at, '3875c12e-fdaa-4ef6-a340-c936e054b627' FROM Contact`) + await queryRunner.query(`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"`)