allow organizations to have multiple subscriptions. although only 1 can be active at a time

This commit is contained in:
m5r
2021-10-03 18:19:45 +02:00
parent 22e2b21b14
commit 3a3d526e77
6 changed files with 65 additions and 37 deletions

View File

@ -0,0 +1,14 @@
/*
Warnings:
- Made the column `organizationId` on table `Subscription` required. This step will fail if there are existing NULL values in that column.
*/
-- DropIndex
DROP INDEX "Subscription_organizationId_unique";
-- AlterTable
ALTER TABLE "Subscription" ALTER COLUMN "organizationId" SET NOT NULL;
-- AlterTable
ALTER TABLE "User" ALTER COLUMN "fullName" DROP DEFAULT;

View File

@ -30,7 +30,7 @@ model Organization {
messages Message[]
phoneCalls PhoneCall[]
processingPhoneNumbers ProcessingPhoneNumber[]
subscription Subscription?
subscriptions Subscription[]
@@unique([id, twilioAccountSid])
}
@ -50,8 +50,8 @@ model Subscription {
nextBillDate DateTime @db.Date
lastEventTime DateTime @db.Timestamp
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade)
organizationId String?
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
organizationId String
}
enum SubscriptionStatus {
@ -95,7 +95,7 @@ model User {
id String @id @default(uuid())
createdAt DateTime @default(now()) @db.Timestamptz
updatedAt DateTime @updatedAt @db.Timestamptz
fullName String @default("")
fullName String
email String @unique
hashedPassword String?
role GlobalRole @default(CUSTOMER)