-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdatabase.sql
More file actions
150 lines (143 loc) · 4 KB
/
database.sql
File metadata and controls
150 lines (143 loc) · 4 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
-- ##### Create Database Order ####
-- Drop table
-- DROP TABLE public.event_state;
CREATE TABLE public.event_state (
id bigserial NOT NULL,
trx_code varchar NULL,
trx_status bool NULL,
created_by varchar NULL,
created_on timestamp NULL,
modified_by varchar NULL,
modified_on timestamp NULL
);
-- Drop table
-- DROP TABLE public.event_state_detail;
CREATE TABLE public.event_state_detail (
id bigserial NOT NULL,
trx_code varchar NULL,
service_name varchar NULL,
status bool NULL,
created_by varchar NULL,
created_on timestamp NULL,
modified_by varchar NULL,
modified_on timestamp NULL,
remarks varchar(256) NULL,
payload text NULL
);
-- Drop table
-- DROP TABLE public.http_log;
CREATE TABLE public.http_log (
id bigserial NOT NULL,
request_time timestamp NULL,
endpoint_name varchar NULL,
request text NULL,
response text NULL,
created_by varchar NULL,
created_on timestamp NULL,
modified_by varchar NULL,
modified_on timestamp NULL
);
-- Drop table
-- DROP TABLE public.trx_order;
CREATE TABLE public.trx_order (
id bigserial NOT NULL,
trx_code varchar NULL,
customer_id int8 NULL,
total_price float8 NULL,
created_by varchar NULL,
created_on timestamp NULL,
modified_by varchar NULL,
modified_on timestamp NULL,
status bool NULL,
CONSTRAINT order_pkey PRIMARY KEY (id)
);
-- Drop table
-- DROP TABLE public.trx_order_detail;
CREATE TABLE public.trx_order_detail (
id bigserial NOT NULL,
product_id int8 NULL,
quantity int4 NULL,
price float8 NULL,
created_by varchar NULL,
created_on timestamp NULL,
modified_by varchar NULL,
modified_on timestamp NULL,
order_id int8 NULL,
CONSTRAINT trx_order_detail_pkey PRIMARY KEY (id),
CONSTRAINT trx_order_detail_fk FOREIGN KEY (order_id) REFERENCES trx_order(id)
);
-- #### Create Database Inventory ####
-- Drop table
-- DROP TABLE public.trx_inventory_header;
CREATE TABLE public.trx_inventory_header (
id bigserial NOT NULL,
current_stock int4 NULL,
trx_code varchar NULL,
product_id int8 NULL,
created_by varchar NULL,
created_on timestamp NULL,
modified_by varchar NULL,
modified_on timestamp NULL,
CONSTRAINT trx_inventory_header_pk PRIMARY KEY (id)
);
-- Drop table
-- DROP TABLE public.trx_inventory_detail;
CREATE TABLE public.trx_inventory_detail (
id bigserial NOT NULL,
product_id int8 NULL,
stock_in int4 NULL,
stock_out int4 NULL,
created_by varchar NULL,
created_on timestamp NULL,
modified_by varchar NULL,
modified_on timestamp NULL,
inventory_header_id int8 NULL,
CONSTRAINT trx_inventory_detail_pkey PRIMARY KEY (id),
CONSTRAINT trx_inventory_detail_fk FOREIGN KEY (inventory_header_id) REFERENCES trx_inventory_header(id)
);
-- #### Create Database Payment ####
-- Drop table
-- DROP TABLE public.trx_payment;
CREATE TABLE public.trx_payment (
id bigserial NOT NULL,
transaction_code varchar NULL,
payment_total float8 NULL,
payment_type varchar NULL,
payment_status varchar NULL,
created_by varchar NULL,
created_on timestamp NULL,
modified_by varchar NULL,
modified_on timestamp NULL,
CONSTRAINT trx_payment_pk PRIMARY KEY (id)
);
-- #### Create Database Product ####
-- Drop table
-- DROP TABLE public.mst_product;
CREATE TABLE public.mst_product (
id bigserial NOT NULL,
name varchar NULL,
created_by varchar NULL,
created_on timestamp NULL,
modified_by varchar NULL,
modified_on timestamp NULL,
current_stock int4 NULL,
transaction_code varchar NULL,
previous_stock int4 NULL,
CONSTRAINT " mst_product_pkey" PRIMARY KEY (id)
);
-- Insert Sample Data Into Product
INSERT INTO public.mst_product
("name", created_by, created_on, modified_by, modified_on, current_stock, transaction_code, previous_stock)
VALUES('Item 1', 'ADMIN', '2019-08-06 11:17:38', 'ADMIN', '2019-08-22 15:14:56', 100, '', 0);
-- #### Create Database customer ####
-- Drop table
-- DROP TABLE public.mst_customer;
CREATE TABLE public.mst_customer (
id bigserial NOT NULL,
user_name varchar NULL,
created_by varchar NULL,
created_on timestamp NULL,
modified_by varchar NULL,
modified_on timestamp NULL,
CONSTRAINT mst_customer_pkey PRIMARY KEY (id)
);