Skip to content

Commit 9238fc4

Browse files
authored
Merge pull request #219 from patrickNwafo/feat/issue-112-organization-ownership
feat(schema): add ownership tracking to organization entity
2 parents fc5752d + 6bc6e54 commit 9238fc4

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
Warnings:
3+
4+
- Added the required column `ownerId` to the `organizations` table without a default value. This is not possible if the table is not empty.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "organizations" ADD COLUMN "ownerId" TEXT NOT NULL;
9+
10+
-- CreateIndex
11+
CREATE INDEX "organizations_ownerId_idx" ON "organizations"("ownerId");
12+
13+
-- AddForeignKey
14+
ALTER TABLE "organizations" ADD CONSTRAINT "organizations_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

prisma/schema.prisma

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ model User {
1818
assignedIncidents Incident[]
1919
memberships Membership[]
2020
invitationsSent Invitation[]
21+
ownedOrganizations Organization[] @relation("OrganizationOwner")
2122
2223
@@map("users")
2324
}
@@ -268,11 +269,14 @@ model ProtocolHealthAlert {
268269
model Organization {
269270
id String @id @default(cuid())
270271
name String
272+
ownerId String
271273
createdAt DateTime @default(now())
272274
275+
owner User @relation("OrganizationOwner", fields: [ownerId], references: [id])
273276
memberships Membership[]
274277
invitations Invitation[]
275278
279+
@@index([ownerId])
276280
@@map("organizations")
277281
}
278282

0 commit comments

Comments
 (0)