From ed55c696cd083bfaa5429082a9c5edd4ebde0cd8 Mon Sep 17 00:00:00 2001
From: Sebastien Castiel <sebastien@castiel.me>
Date: Tue, 5 Dec 2023 17:39:05 -0500
Subject: First version

---
 .../20231205211834_create_models/migration.sql     | 46 ++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 prisma/migrations/20231205211834_create_models/migration.sql

(limited to 'prisma/migrations/20231205211834_create_models/migration.sql')

diff --git a/prisma/migrations/20231205211834_create_models/migration.sql b/prisma/migrations/20231205211834_create_models/migration.sql
new file mode 100644
index 0000000..babd781
--- /dev/null
+++ b/prisma/migrations/20231205211834_create_models/migration.sql
@@ -0,0 +1,46 @@
+-- CreateTable
+CREATE TABLE "Group" (
+    "id" TEXT NOT NULL,
+    "name" TEXT NOT NULL,
+
+    CONSTRAINT "Group_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "Participant" (
+    "id" TEXT NOT NULL,
+    "name" TEXT NOT NULL,
+    "groupId" TEXT NOT NULL,
+
+    CONSTRAINT "Participant_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "Expense" (
+    "id" TEXT NOT NULL,
+    "title" TEXT NOT NULL,
+    "amount" DECIMAL(65,30) NOT NULL,
+    "paidById" TEXT NOT NULL,
+
+    CONSTRAINT "Expense_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "ExpensePaidFor" (
+    "expenseId" TEXT NOT NULL,
+    "participantId" TEXT NOT NULL,
+
+    CONSTRAINT "ExpensePaidFor_pkey" PRIMARY KEY ("expenseId","participantId")
+);
+
+-- AddForeignKey
+ALTER TABLE "Participant" ADD CONSTRAINT "Participant_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "Group"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "Expense" ADD CONSTRAINT "Expense_paidById_fkey" FOREIGN KEY ("paidById") REFERENCES "Participant"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "ExpensePaidFor" ADD CONSTRAINT "ExpensePaidFor_expenseId_fkey" FOREIGN KEY ("expenseId") REFERENCES "Expense"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "ExpensePaidFor" ADD CONSTRAINT "ExpensePaidFor_participantId_fkey" FOREIGN KEY ("participantId") REFERENCES "Participant"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- 
cgit v1.3

