summaryrefslogtreecommitdiff
path: root/prisma/schema.prisma
blob: 68bc38746bc771bac8fa0c864b9d8633b0d97d8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
generator client {
    provider = "prisma-client-js"
    output   = "./generated/client"
}

datasource db {
    provider = "postgresql"
    url      = env("DB_URL")
}

model Company {
    id           Int           @id @default(autoincrement())
    name         String
    users        User[]
    locations    Location[]
    products     Product[]
    stockOpnames StockOpname[]
}

model User {
    id           Int           @id @default(autoincrement())
    name         String
    company      Company       @relation(fields: [companyId], references: [id])
    companyId    Int
    username     String        @unique
    password     String
    stockOpnames StockOpname[]
    team         Team
}

model Location {
    id           Int           @id @default(autoincrement())
    name         String
    company      Company       @relation(fields: [companyId], references: [id])
    companyId    Int
    stockOpnames StockOpname[]
}

model Product {
    id            Int           @id @default(autoincrement())
    externalId    String?
    value         Float? 
    barcode       String
    itemCode      String
    name          String
    onhandQty     Int
    differenceQty Int
    isDifferent   Boolean
    company       Company       @relation(fields: [companyId], references: [id])
    companyId     Int
    stockOpnames  StockOpname[]
}

model StockOpname {
    id          Int      @id @default(autoincrement())
    product     Product  @relation(fields: [productId], references: [id])
    productId   Int
    location    Location @relation(fields: [locationId], references: [id])
    locationId  Int
    company     Company  @relation(fields: [companyId], references: [id])
    companyId   Int
    user        User     @relation(fields: [userId], references: [id])
    userId      Int
    team        Team
    quantity    Int
    isDifferent Boolean
}

enum Team {
    COUNT1
    COUNT2
    COUNT3
    VERIFICATION
}