diff --git a/apps/user/src/user.service.ts b/apps/user/src/user.service.ts index 0f5a84c9a..19b057c14 100644 --- a/apps/user/src/user.service.ts +++ b/apps/user/src/user.service.ts @@ -338,7 +338,10 @@ export class UserService { async getProfile(payload: { id }): Promise { try { - return this.userRepository.getUserById(payload.id); + const userData = await this.userRepository.getUserById(payload.id); + const platformConfigData = await this.prisma.platform_config.findMany(); + userData['enableEcosystem'] = platformConfigData[0].enableEcosystem; + return userData; } catch (error) { this.logger.error(`get user: ${JSON.stringify(error)}`); throw new RpcException(error.response ? error.response : error); diff --git a/libs/prisma-service/prisma/data/credebl-master-table.json b/libs/prisma-service/prisma/data/credebl-master-table.json index 35a44c6c3..c1627506f 100644 --- a/libs/prisma-service/prisma/data/credebl-master-table.json +++ b/libs/prisma-service/prisma/data/credebl-master-table.json @@ -55,6 +55,21 @@ "description": "Joins the organization as member" } ], + "ecosystemRoleData": [ + { + "name": "Ecosystem Owner", + "description": "Ecosystem Owner" + }, + { + "name": "Ecosystem Lead", + "description": "Ecosystem Lead" + }, + { + "name": "Ecosystem Member", + "description": "Ecosystem Member" + } + ], + "agentTypeData": [ { "agent": "AFJ" diff --git a/libs/prisma-service/prisma/migrations/20231003080927_ecosystem_flag/migration.sql b/libs/prisma-service/prisma/migrations/20231003080927_ecosystem_flag/migration.sql new file mode 100644 index 000000000..418d645c7 --- /dev/null +++ b/libs/prisma-service/prisma/migrations/20231003080927_ecosystem_flag/migration.sql @@ -0,0 +1,24 @@ +/* + Warnings: + + - The primary key for the `ecosystem_roles` table will be changed. If it partially fails, the table could be left without primary key constraint. + +*/ +-- DropForeignKey +ALTER TABLE "ecosystem_orgs" DROP CONSTRAINT "ecosystem_orgs_ecosystemRoleId_fkey"; + +-- AlterTable +ALTER TABLE "ecosystem_orgs" ALTER COLUMN "ecosystemRoleId" SET DATA TYPE TEXT; + +-- AlterTable +ALTER TABLE "ecosystem_roles" DROP CONSTRAINT "ecosystem_roles_pkey", +ALTER COLUMN "id" DROP DEFAULT, +ALTER COLUMN "id" SET DATA TYPE TEXT, +ADD CONSTRAINT "ecosystem_roles_pkey" PRIMARY KEY ("id"); +DROP SEQUENCE "ecosystem_roles_id_seq"; + +-- AlterTable +ALTER TABLE "platform_config" ADD COLUMN "enableEcosystem" BOOLEAN NOT NULL DEFAULT false; + +-- AddForeignKey +ALTER TABLE "ecosystem_orgs" ADD CONSTRAINT "ecosystem_orgs_ecosystemRoleId_fkey" FOREIGN KEY ("ecosystemRoleId") REFERENCES "ecosystem_roles"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/libs/prisma-service/prisma/migrations/20231003114625_ecosystem_logo/migration.sql b/libs/prisma-service/prisma/migrations/20231003114625_ecosystem_logo/migration.sql new file mode 100644 index 000000000..d4031a104 --- /dev/null +++ b/libs/prisma-service/prisma/migrations/20231003114625_ecosystem_logo/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "ecosystem" ADD COLUMN "logoUrl" TEXT; diff --git a/libs/prisma-service/prisma/schema.prisma b/libs/prisma-service/prisma/schema.prisma index 9a6cf2497..4ba8e17e7 100644 --- a/libs/prisma-service/prisma/schema.prisma +++ b/libs/prisma-service/prisma/schema.prisma @@ -132,6 +132,7 @@ model platform_config { emailFrom String @db.VarChar apiEndpoint String @db.VarChar tailsFileServer String @db.VarChar + enableEcosystem Boolean @default(false) createDateTime DateTime @default(now()) @db.Timestamptz(6) createdBy Int @default(1) lastChangedDateTime DateTime @default(now()) @db.Timestamptz(6) @@ -309,7 +310,7 @@ model presentations { } model ecosystem_roles { - id Int @id @default(autoincrement()) + id String @id @default(uuid()) name String @unique description String ecosystemOrgs ecosystem_orgs[] @@ -324,6 +325,7 @@ model ecosystem { id String @id @default(uuid()) name String description String + logoUrl String? tags String ecosystemOrgs ecosystem_orgs[] ecosystemUsers ecosystem_users[] @@ -363,11 +365,11 @@ model ecosystem_users { } model ecosystem_orgs { - id String @id @default(uuid()) // auto-increment + id String @id @default(uuid()) orgId String status String ecosystemId String - ecosystemRoleId Int + ecosystemRoleId String ecosystem ecosystem @relation(fields: [ecosystemId], references: [id]) ecosystemRole ecosystem_roles @relation(fields: [ecosystemRoleId], references: [id]) createDateTime DateTime @default(now()) @db.Timestamptz(6) diff --git a/libs/prisma-service/prisma/seed.ts b/libs/prisma-service/prisma/seed.ts index 8b6b6fb51..cd50a00c6 100644 --- a/libs/prisma-service/prisma/seed.ts +++ b/libs/prisma-service/prisma/seed.ts @@ -113,6 +113,19 @@ const createLedger = async (): Promise => { } }; +const createEcosystemRoles = async (): Promise => { + try { + const { ecosystemRoleData } = JSON.parse(configData); + const ecosystemRoles = await prisma.ecosystem_roles.createMany({ + data: ecosystemRoleData + }); + + logger.log(ecosystemRoles); + } catch (e) { + logger.error('An error occurred seeding ecosystemRoles:', e); + } +}; + async function main(): Promise { await createPlatformConfig(); @@ -123,6 +136,7 @@ async function main(): Promise { await createPlatformUserOrgRoles(); await createOrgAgentTypes(); await createLedger(); + await createEcosystemRoles(); }