Skip to content

Commit

Permalink
schema.prisma:Affiliate: Make companyId not null
Browse files Browse the repository at this point in the history
  • Loading branch information
sashko9807 committed Oct 24, 2023
1 parent 4de21df commit 480524a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class Affiliate {
id: string
status: AffiliateStatus
affiliateCode: string | null
companyId: string | null
company?: Company | null
companyId: string
company?: Company
donations?: Donation[]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
Warnings:
- Made the column `company_id` on table `affiliates` required. This step will fail if there are existing NULL values in that column.
*/
-- DropForeignKey
ALTER TABLE "affiliates" DROP CONSTRAINT "affiliates_company_id_fkey";

-- AlterTable
ALTER TABLE "affiliates" ALTER COLUMN "company_id" SET NOT NULL;

-- AddForeignKey
ALTER TABLE "affiliates" ADD CONSTRAINT "affiliates_company_id_fkey" FOREIGN KEY ("company_id") REFERENCES "companies"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
4 changes: 2 additions & 2 deletions schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ model Affiliate {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
status AffiliateStatus @default(pending)
affiliateCode String? @unique @map("affiliate_code")
companyId String? @unique @map("company_id") @db.Uuid
company Company? @relation(fields: [companyId], references: [id])
companyId String @unique @map("company_id") @db.Uuid
company Company @relation(fields: [companyId], references: [id])
donations Donation[]
@@map("affiliates")
Expand Down

0 comments on commit 480524a

Please sign in to comment.