Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
Warnings:

- Added the required column `ownerId` to the `organizations` table without a default value. This is not possible if the table is not empty.

*/
-- AlterTable
ALTER TABLE "organizations" ADD COLUMN "ownerId" TEXT NOT NULL;

-- CreateIndex
CREATE INDEX "organizations_ownerId_idx" ON "organizations"("ownerId");

-- AddForeignKey
ALTER TABLE "organizations" ADD CONSTRAINT "organizations_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
4 changes: 4 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ model User {
assignedIncidents Incident[]
memberships Membership[]
invitationsSent Invitation[]
ownedOrganizations Organization[] @relation("OrganizationOwner")

@@map("users")
}
Expand Down Expand Up @@ -268,11 +269,14 @@ model ProtocolHealthAlert {
model Organization {
id String @id @default(cuid())
name String
ownerId String
createdAt DateTime @default(now())

owner User @relation("OrganizationOwner", fields: [ownerId], references: [id])
memberships Membership[]
invitations Invitation[]

@@index([ownerId])
@@map("organizations")
}

Expand Down
Loading