mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-24 16:36:12 +01:00
Migration script, improvements in expenses list
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Expense" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Group" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||
@@ -0,0 +1,17 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Expense" DROP CONSTRAINT "Expense_groupId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Expense" DROP CONSTRAINT "Expense_paidById_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "ExpensePaidFor" DROP CONSTRAINT "ExpensePaidFor_participantId_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Expense" ADD CONSTRAINT "Expense_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "Group"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Expense" ADD CONSTRAINT "Expense_paidById_fkey" FOREIGN KEY ("paidById") REFERENCES "Participant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ExpensePaidFor" ADD CONSTRAINT "ExpensePaidFor_participantId_fkey" FOREIGN KEY ("participantId") REFERENCES "Participant"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -17,6 +17,7 @@ model Group {
|
||||
currency String @default("$")
|
||||
participants Participant[]
|
||||
expenses Expense[]
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model Participant {
|
||||
@@ -30,19 +31,20 @@ model Participant {
|
||||
|
||||
model Expense {
|
||||
id String @id
|
||||
group Group @relation(fields: [groupId], references: [id])
|
||||
group Group @relation(fields: [groupId], references: [id], onDelete: Cascade)
|
||||
title String
|
||||
amount Int
|
||||
paidBy Participant @relation(fields: [paidById], references: [id])
|
||||
paidBy Participant @relation(fields: [paidById], references: [id], onDelete: Cascade)
|
||||
paidById String
|
||||
paidFor ExpensePaidFor[]
|
||||
groupId String
|
||||
isReimbursement Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model ExpensePaidFor {
|
||||
expense Expense @relation(fields: [expenseId], references: [id], onDelete: Cascade)
|
||||
participant Participant @relation(fields: [participantId], references: [id])
|
||||
participant Participant @relation(fields: [participantId], references: [id], onDelete: Cascade)
|
||||
expenseId String
|
||||
participantId String
|
||||
|
||||
|
||||
Reference in New Issue
Block a user