-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdatabase.sql
More file actions
69 lines (68 loc) · 2.6 KB
/
Copy pathdatabase.sql
File metadata and controls
69 lines (68 loc) · 2.6 KB
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
-- WARNING: This schema is for context only and is not meant to be run.
-- Table order and constraints may not be valid for execution.
CREATE TABLE public.Category (
id text NOT NULL,
name text NOT NULL,
description text,
type text NOT NULL DEFAULT 'expense'::text,
createdAt timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updatedAt timestamp without time zone NOT NULL,
organizationId text NOT NULL,
userId text NOT NULL,
CONSTRAINT Category_pkey PRIMARY KEY (id)
);
CREATE TABLE public.Item (
id text NOT NULL,
name text NOT NULL,
itemPrice double precision NOT NULL,
quantity integer NOT NULL,
totalPrice double precision NOT NULL,
organizationId text NOT NULL,
userId text NOT NULL,
masterItemId text,
transactionId integer NOT NULL,
CONSTRAINT Item_pkey PRIMARY KEY (id),
CONSTRAINT Item_transactionId_fkey FOREIGN KEY (transactionId) REFERENCES public.Transaction(id),
CONSTRAINT Item_masterItemId_fkey FOREIGN KEY (masterItemId) REFERENCES public.MasterItem(id)
);
CREATE TABLE public.MasterItem (
id text NOT NULL,
name text NOT NULL,
description text,
defaultPrice double precision NOT NULL,
type text NOT NULL DEFAULT 'expense'::text,
createdAt timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updatedAt timestamp without time zone NOT NULL,
organizationId text NOT NULL,
userId text NOT NULL,
CONSTRAINT MasterItem_pkey PRIMARY KEY (id)
);
CREATE TABLE public.RelatedParty (
id text NOT NULL,
name text NOT NULL,
description text,
contactInfo text,
type text NOT NULL DEFAULT 'expense'::text,
createdAt timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updatedAt timestamp without time zone NOT NULL,
organizationId text NOT NULL,
userId text NOT NULL,
CONSTRAINT RelatedParty_pkey PRIMARY KEY (id)
);
CREATE TABLE public.Transaction (
id integer NOT NULL DEFAULT nextval('"Transaction_id_seq"'::regclass),
createdAt timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updatedAt timestamp without time zone NOT NULL,
date timestamp without time zone NOT NULL,
description text NOT NULL,
amountTotal double precision NOT NULL,
paymentImg text NOT NULL DEFAULT ''::text,
type text NOT NULL DEFAULT 'pengeluaran'::text,
organizationId text NOT NULL,
userId text NOT NULL,
categoryId text NOT NULL,
relatedPartyId text NOT NULL,
CONSTRAINT Transaction_pkey PRIMARY KEY (id),
CONSTRAINT Transaction_relatedPartyId_fkey FOREIGN KEY (relatedPartyId) REFERENCES public.RelatedParty(id),
CONSTRAINT Transaction_categoryId_fkey FOREIGN KEY (categoryId) REFERENCES public.Category(id)
);