Skip to content

Commit

Permalink
feat: adds match_confirmation tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Camila Cardoso authored and Camila Cardoso committed Jul 18, 2024
1 parent f714baa commit 45ffb03
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- CreateEnum
CREATE TYPE "match"."match_confirmation_status" AS ENUM ('waiting', 'confirmed', 'denied', 'failed');

-- CreateTable
CREATE TABLE "match"."match_confirmations" (
"match_confirmation_id" SERIAL NOT NULL,
"support_request_id" INTEGER NOT NULL,
"msr_id" BIGINT NOT NULL,
"volunteer_id" INTEGER,
"status" "match"."match_confirmation_status" NOT NULL,
"match_id" INTEGER,
"created_at" TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(6) NOT NULL,

CONSTRAINT "match_confirmations_pkey" PRIMARY KEY ("match_confirmation_id")
);

-- CreateTable
CREATE TABLE "match"."match_confirmation_status_history" (
"match_confirmation_status_history_id" SERIAL NOT NULL,
"match_confirmation_id" INTEGER NOT NULL,
"status" "match"."match_confirmation_status" NOT NULL,
"created_at" TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "match_confirmation_status_history_pkey" PRIMARY KEY ("match_confirmation_status_history_id")
);

-- AddForeignKey
ALTER TABLE "match"."match_confirmations" ADD CONSTRAINT "match_confirmations_support_request_id_fkey" FOREIGN KEY ("support_request_id") REFERENCES "match"."support_requests"("support_request_id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "match"."match_confirmation_status_history" ADD CONSTRAINT "match_confirmation_status_history_match_confirmation_id_fkey" FOREIGN KEY ("match_confirmation_id") REFERENCES "match"."match_confirmations"("match_confirmation_id") ON DELETE RESTRICT ON UPDATE CASCADE;
51 changes: 45 additions & 6 deletions schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,20 @@ model MSRs {
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(6)
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamp(6)
MSRPii MSRPiiSec?
MSRPii MSRPiiSec?
@@map("msrs")
@@schema("msr")
}

model MSRPiiSec {
msrId BigInt @id @default(autoincrement()) @map("msr_id")
msrId BigInt @id @default(autoincrement()) @map("msr_id")
firstName String? @map("first_name") @db.VarChar(200)
email String @unique @db.VarChar(254)
phone String @db.VarChar(100)
email String @unique @db.VarChar(254)
phone String @db.VarChar(100)
dateOfBirth DateTime? @map("date_of_birth") @db.Date
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(6)
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamp(6)
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(6)
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamp(6)
MSRs MSRs @relation(fields: [msrId], references: [msrId])
Expand All @@ -276,6 +276,7 @@ model SupportRequests {
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(6)
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamp(6)
Matches Matches[]
MatchConfirmations MatchConfirmations[]
SupportRequestStatusHistory SupportRequestStatusHistory[]
@@map("support_requests")
Expand Down Expand Up @@ -315,6 +316,34 @@ model Matches {
@@schema("match")
}

model MatchConfirmations {
matchConfirmationId Int @id @default(autoincrement()) @map("match_confirmation_id")
supportRequestId Int @map("support_request_id")
msrId BigInt @map("msr_id")
volunteerId Int? @map("volunteer_id")
status MatchConfirmationStatus
matchId Int? @map("match_id")
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(6)
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamp(6)
SupportRequest SupportRequests @relation(fields: [supportRequestId], references: [supportRequestId])
MatchConfirmationStatusHistory MatchConfirmationStatusHistory[]
@@map("match_confirmations")
@@schema("match")
}

model MatchConfirmationStatusHistory {
matchConfirmationStatusHistoryId Int @id @default(autoincrement()) @map("match_confirmation_status_history_id")
matchConfirmationId Int @map("match_confirmation_id")
status MatchConfirmationStatus
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(6)
MatchConfirmation MatchConfirmations @relation(fields: [matchConfirmationId], references: [matchConfirmationId])
@@map("match_confirmation_status_history")
@@schema("match")
}

model MatchStatusHistory {
matchStatusHistoryId Int @id @default(autoincrement()) @map("match_status_history_id")
matchId Int @map("match_id")
Expand Down Expand Up @@ -616,6 +645,16 @@ enum MatchStatus {
@@schema("match")
}

enum MatchConfirmationStatus {
waiting
confirmed
denied
failed
@@map("match_confirmation_status")
@@schema("match")
}

enum SurveyType {
triagem_1
triagem_2
Expand Down

0 comments on commit 45ffb03

Please sign in to comment.