ADD: added some quiality of life features
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `invoices` ADD COLUMN `deletedAt` DATETIME(3) NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `invoices` MODIFY `number` VARCHAR(191) NULL;
|
||||
@@ -0,0 +1,17 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `services` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`companyId` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`description` TEXT NULL,
|
||||
`unit` VARCHAR(191) NULL,
|
||||
`unitPrice` DECIMAL(10, 2) NOT NULL,
|
||||
`taxRate` DECIMAL(5, 2) NOT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `services` ADD CONSTRAINT `services_companyId_fkey` FOREIGN KEY (`companyId`) REFERENCES `companies`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
+18
-1
@@ -69,12 +69,28 @@ model Company {
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
customers Customer[]
|
||||
invoices Invoice[]
|
||||
services Service[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("companies")
|
||||
}
|
||||
|
||||
model Service {
|
||||
id String @id @default(cuid())
|
||||
companyId String
|
||||
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
description String? @db.Text
|
||||
unit String?
|
||||
unitPrice Decimal @db.Decimal(10, 2)
|
||||
taxRate Decimal @db.Decimal(5, 2)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("services")
|
||||
}
|
||||
|
||||
model Customer {
|
||||
id String @id @default(cuid())
|
||||
companyId String
|
||||
@@ -96,7 +112,7 @@ model Customer {
|
||||
|
||||
model Invoice {
|
||||
id String @id @default(cuid())
|
||||
number String
|
||||
number String?
|
||||
companyId String
|
||||
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
|
||||
customerId String
|
||||
@@ -113,6 +129,7 @@ model Invoice {
|
||||
grossTotal Decimal @db.Decimal(10, 2)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime?
|
||||
|
||||
@@unique([companyId, number])
|
||||
@@map("invoices")
|
||||
|
||||
Reference in New Issue
Block a user