· 6 years ago · Oct 27, 2019, 01:03 PM
1CREATE TABLE IF NOT EXISTS users(
2 id SERIAL PRIMARY KEY,
3 username varchar(255) NOT NULL,
4 email varchar(255) NOT NULL,
5 password varchar(255) NOT NULL,
6 enabled INTEGER DEFAULT 0,
7 created_at timestamp,
8 modified_at timestamp,
9 removed_at timestamp
10);
11
12CREATE TABLE IF NOT EXISTS authorities(
13 id SERIAL PRIMARY KEY,
14 user_id INTEGER REFERENCES users(id),
15 username varchar(255) NOT NULL,
16 authority varchar(50) NOT NULL
17);
18
19CREATE TABLE IF NOT EXISTS places(
20 id SERIAL PRIMARY KEY,
21 user_id INTEGER REFERENCES users(id),
22 name varchar(255) NOT NULL,
23 address varchar(255) NOT NULL,
24 large_description varchar(1024) NOT NULL,
25 small_description varchar(100) NOT NULL,
26 created_at timestamp,
27 modified_at timestamp,
28 removed_at timestamp
29);
30
31CREATE TABLE IF NOT EXISTS place_urls(
32 id SERIAL PRIMARY KEY,
33 place_id INTEGER REFERENCES places(id),
34 url varchar(255) NOT NULL,
35 created_at timestamp,
36 modified_at timestamp,
37 removed_at timestamp
38);
39
40CREATE TABLE IF NOT EXISTS bookings(
41 id SERIAL PRIMARY KEY,
42 place_id INTEGER REFERENCES places(id),
43 name varchar(255) NOT NULL,
44 phonenumber varchar(255) NOT NULL,
45 reservation_date date NOT NULL,
46 receipt_number varchar(25) NOT NULL,
47 created_at timestamp,
48 modified_at timestamp,
49 removed_at timestamp
50);
51
52CREATE TABLE IF NOT EXISTS companies(
53 id SERIAL PRIMARY KEY,
54 user_id INTEGER REFERENCES users(id),
55 name varchar(255),
56 address varchar(255),
57 modified_at timestamp
58);
59
60CREATE TABLE IF NOT EXISTS contacts(
61 id SERIAL PRIMARY KEY,
62 user_id INTEGER REFERENCES users(id),
63 first_name varchar(255),
64 last_name varchar(255),
65 address varchar(255),
66 phonenumber varchar(255),
67 modified_at timestamp
68);