-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1_init_db.sql
100 lines (86 loc) · 2.27 KB
/
1_init_db.sql
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
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TABLE organization (
id serial primary key,
name varchar
);
CREATE TABLE account (
id serial primary key,
public_id uuid,
first_name varchar,
last_name varchar,
email varchar
);
CREATE TABLE membership_type (
id serial primary key,
name varchar
);
CREATE TABLE membership (
id serial primary key,
public_id uuid,
account_id integer not null references account (id),
membership_type_id integer not null references membership_type (id),
organization_id integer not null references organization (id),
status varchar,
created_ts timestamp
);
CREATE TABLE product (
id serial primary key,
public_id uuid,
name varchar,
msrp numeric(10,2)
);
CREATE TABLE location (
id serial primary key,
name varchar
);
CREATE TABLE model (
id serial primary key,
public_id uuid,
name varchar,
manufacturer varchar,
seats integer,
doors integer,
fuel_type varchar
);
CREATE TABLE car (
id serial primary key,
public_id uuid,
license_number varchar,
model_id integer not null references model (id),
color varchar,
owner_organization integer not null references organization (id)
);
CREATE TABLE car_location_assignment (
car_id integer not null references car (id),
location_id integer references location (id),
start_time timestamp,
PRIMARY KEY(car_id, location_id)
);
CREATE TABLE reservation (
id serial primary key,
public_id uuid,
membership_id integer not null references membership (id),
car_id integer not null references car (id),
planned_start timestamp,
planned_end timestamp,
state varchar
);
CREATE TABLE invoice (
id serial primary key,
public_id uuid,
membership_id integer references membership (id),
status varchar
);
CREATE TABLE order_line (
id serial primary key,
public_id uuid,
membership_id integer references membership (id),
reservation_id integer references reservation (id),
product_id integer not null references product (id),
count integer,
total numeric(10,2),
invoice_id integer references invoice (id),
created timestamp
);
ALTER SYSTEM SET shared_buffers = '2GB';
ALTER SYSTEM SET max_parallel_workers_per_gather = 0;