Skip to content

Commit 733dfd4

Browse files
author
David Arevalo
committed
update docker-compose
1 parent b722b0a commit 733dfd4

File tree

5 files changed

+106
-103
lines changed

5 files changed

+106
-103
lines changed

database.env

Lines changed: 0 additions & 3 deletions
This file was deleted.

docker-compose-postgres.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: '3.7'
2+
services:
3+
postgres:
4+
image: postgres:10.5
5+
restart: always
6+
environment:
7+
- POSTGRES_USER=postgres
8+
- POSTGRES_PASSWORD=postgres
9+
logging:
10+
options:
11+
max-size: 10m
12+
max-file: "3"
13+
ports:
14+
- '5438:5432'
15+
volumes:
16+
- ./postgres-data:/var/lib/postgresql/data
17+
# copy the sql script to create tables
18+
- ./sql/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql
19+
#command:
20+
#- |
21+
#psql -U postgres test -f '/sql/create_tables.sql'

sql/create_data.sql

Lines changed: 0 additions & 85 deletions
This file was deleted.

sql/create_tables.sql

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
-- Creation of product table
2+
CREATE TABLE IF NOT EXISTS product (
3+
product_id INT NOT NULL,
4+
name varchar(250) NOT NULL,
5+
PRIMARY KEY (product_id)
6+
);
7+
8+
-- Creation of country table
9+
CREATE TABLE IF NOT EXISTS country (
10+
country_id INT NOT NULL,
11+
country_name varchar(450) NOT NULL,
12+
PRIMARY KEY (country_id)
13+
);
14+
15+
-- Creation of city table
16+
CREATE TABLE IF NOT EXISTS city (
17+
city_id INT NOT NULL,
18+
city_name varchar(450) NOT NULL,
19+
country_id INT NOT NULL,
20+
PRIMARY KEY (city_id),
21+
CONSTRAINT fk_country
22+
FOREIGN KEY(country_id)
23+
REFERENCES country(country_id)
24+
);
25+
26+
-- Creation of store table
27+
CREATE TABLE IF NOT EXISTS store (
28+
store_id INT NOT NULL,
29+
name varchar(250) NOT NULL,
30+
city_id INT NOT NULL,
31+
PRIMARY KEY (store_id),
32+
CONSTRAINT fk_city
33+
FOREIGN KEY(city_id)
34+
REFERENCES city(city_id)
35+
);
36+
37+
-- Creation of user table
38+
CREATE TABLE IF NOT EXISTS users (
39+
user_id INT NOT NULL,
40+
name varchar(250) NOT NULL,
41+
PRIMARY KEY (user_id)
42+
);
43+
44+
-- Creation of status_name table
45+
CREATE TABLE IF NOT EXISTS status_name (
46+
status_name_id INT NOT NULL,
47+
status_name varchar(450) NOT NULL,
48+
PRIMARY KEY (status_name_id)
49+
);
50+
51+
-- Creation of sale table
52+
CREATE TABLE IF NOT EXISTS sale (
53+
sale_id varchar(200) NOT NULL,
54+
amount DECIMAL(20,3) NOT NULL,
55+
date_sale TIMESTAMP,
56+
product_id INT NOT NULL,
57+
user_id INT NOT NULL,
58+
store_id INT NOT NULL,
59+
PRIMARY KEY (sale_id),
60+
CONSTRAINT fk_product
61+
FOREIGN KEY(product_id)
62+
REFERENCES product(product_id),
63+
CONSTRAINT fk_user
64+
FOREIGN KEY(user_id)
65+
REFERENCES users(user_id),
66+
CONSTRAINT fk_store
67+
FOREIGN KEY(store_id)
68+
REFERENCES store(store_id)
69+
);
70+
71+
-- Creation of order_status table
72+
CREATE TABLE IF NOT EXISTS order_status (
73+
order_status_id varchar(200) NOT NULL,
74+
update_at TIMESTAMP,
75+
sale_id varchar(200) NOT NULL,
76+
status_name_id INT NOT NULL,
77+
PRIMARY KEY (order_status_id),
78+
CONSTRAINT fk_sale
79+
FOREIGN KEY(sale_id)
80+
REFERENCES sale(sale_id),
81+
CONSTRAINT fk_status_name
82+
FOREIGN KEY(status_name_id)
83+
REFERENCES status_name(status_name_id)
84+
);
85+

0 commit comments

Comments
 (0)