This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
services: | |
postgres: | |
image: postgres:10.5 | |
restart: always | |
environment: | |
- POSTGRES_USER=postgres | |
- POSTGRES_PASSWORD=postgres | |
logging: | |
options: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
services: | |
postgres: | |
image: postgres:10.5 | |
restart: always | |
environment: | |
- POSTGRES_USER=postgres | |
- POSTGRES_PASSWORD=postgres | |
logging: | |
options: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Creation of product table | |
CREATE TABLE IF NOT EXISTS product ( | |
product_id INT NOT NULL, | |
name varchar(250) NOT NULL, | |
PRIMARY KEY (product_id) | |
); | |
... | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
for f in /docker-entrypoint-initdb.d/*; do | |
case "$f" in | |
*.sh) | |
if [ -x "$f" ]; then | |
echo "$0: running $f" | |
"$f" | |
else | |
echo "$0: sourcing $f" | |
. "$f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Set params | |
set session my.number_of_sales = '20000'; | |
set session my.number_of_users = '5000'; | |
set session my.number_of_products = '30'; | |
set session my.number_of_stores = '50'; | |
set session my.number_of_coutries = '10'; | |
set session my.number_of_cities = '30'; | |
set session my.status_names = '5'; | |
set session my.start_date = '2019-01-01 00:00:00'; | |
set session my.end_date = '2020-02-01 00:00:00'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
-- Filling of products | |
INSERT INTO product | |
select id, concat('Product ', id) | |
FROM GENERATE_SERIES(1, current_setting('my.number_of_products')::int) as id; | |
... | |
... | |
-- Filling of cities | |
INSERT INTO city |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE EXTENSION pgcrypto; | |
--select gen_random_uuid (); | |
... | |
-- Filling of sales | |
INSERT INTO sale; | |
select gen_random_uuid () | |
, round(CAST(float8 (random() * 10000) as numeric), 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TO_TIMESTAMP(start_date, 'YYYY-MM-DD HH24:MI:SS') + | |
random()* (TO_TIMESTAMP(end_date, 'YYYY-MM-DD HH24:MI:SS') | |
- TO_TIMESTAMP(start_date, 'YYYY-MM-DD HH24:MI:SS')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
floor(random() * (current_setting('my.number_of_products')::int) + 1)::int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Filling of order_status | |
INSERT INTO order_status | |
select gen_random_uuid () | |
, date_sale + random()* (date_sale + '5 days' - date_sale) | |
, sale_id | |
, floor(random() * (current_setting('my.status_names')::int) + 1)::int | |
from sale; |
OlderNewer