Skip to content

Commit

Permalink
Modify Schema (Basic Starter)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmegood committed Jan 26, 2024
1 parent 5c90a97 commit d83341c
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ model User {
roles Role[]
sessions Session[]
connections Connection[]
Transaction Transaction[]
Invoice Invoice[]
}

model Note {
Expand Down Expand Up @@ -167,3 +169,70 @@ model Connection {
@@unique([providerName, providerId])
}

// * Account specific models
// * This is for a simple personal finance app
model Account {
id Int @id @default(autoincrement())
name String
balance Float
type String
transactions Transaction[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model Transaction {
id Int @id @default(autoincrement())
date DateTime @default(now())
description String
amount Float
type String // Could be "income", "expense", "transfer", etc.
account Account @relation(fields: [accountId], references: [id])
accountId Int
createdBy User @relation(fields: [userId], references: [id])
userId String
invoice Invoice? @relation(fields: [invoiceId], references: [id])
invoiceId Int?
category String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model Invoice {
id Int @id @default(autoincrement())
dateIssued DateTime @default(now())
dueDate DateTime
items InvoiceItem[]
totalAmount Float
status String // Could be "paid", "unpaid", "overdue"
createdBy User @relation(fields: [userId], references: [id])
userId String
transactions Transaction[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model InvoiceItem {
id Int @id @default(autoincrement())
invoice Invoice @relation(fields: [invoiceId], references: [id])
invoiceId Int
description String
quantity Int
price Float
total Float @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model Report {
id Int @id @default(autoincrement())
name String
description String?
type String // Could be "balance_sheet", "profit_loss", "cash_flow", etc.
periodStart DateTime
periodEnd DateTime
data String // Assuming the report is complex and might contain various types of data; JSON can be a flexible storage option
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

0 comments on commit d83341c

Please sign in to comment.