mirror of
https://codeberg.org/MarkusThielker/finances.git
synced 2025-04-18 16:41:18 +00:00
N-FIN-42: add default category column to entity
This commit is contained in:
parent
74bb618706
commit
5556901115
2 changed files with 17 additions and 7 deletions
|
@ -0,0 +1,7 @@
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "entities"
|
||||||
|
ADD COLUMN "default_category_id" INTEGER;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "entities"
|
||||||
|
ADD CONSTRAINT "entities_default_category_id_fkey" FOREIGN KEY ("default_category_id") REFERENCES "categories" ("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@ -39,6 +39,8 @@ model Entity {
|
||||||
user User @relation(fields: [userId], references: [id])
|
user User @relation(fields: [userId], references: [id])
|
||||||
name String
|
name String
|
||||||
type EntityType
|
type EntityType
|
||||||
|
defaultCategory Category? @relation(fields: [defaultCategoryId], references: [id])
|
||||||
|
defaultCategoryId Int? @map("default_category_id")
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
createdAt DateTime @default(now()) @map("created_at")
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
updatedAt DateTime @updatedAt @map("updated_at")
|
||||||
|
|
||||||
|
@ -84,6 +86,7 @@ model Category {
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
updatedAt DateTime @updatedAt @map("updated_at")
|
||||||
|
|
||||||
payments Payment[]
|
payments Payment[]
|
||||||
|
Entity Entity[]
|
||||||
|
|
||||||
@@unique(fields: [userId, name])
|
@@unique(fields: [userId, name])
|
||||||
@@map("categories")
|
@@map("categories")
|
||||||
|
|
Loading…
Add table
Reference in a new issue