From 462ee42f985e2aa54fbb6974128a2b725394924e Mon Sep 17 00:00:00 2001 From: realaltffour <56314286+realaltffour@users.noreply.github.com> Date: Mon, 20 Jul 2020 11:43:25 +0300 Subject: [PATCH] add: sql init scripts execution --- DockerFiles/master_server.yml | 1 + src/libtrader/db/sql/000_table_companies.sql | 16 ++++++++-------- src/libtrader/db/sql/002_table_stock.sql | 10 +++++----- src/libtrader/db/sql/004_table_sessions.sql | 6 +++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/DockerFiles/master_server.yml b/DockerFiles/master_server.yml index ae71d67..1782e21 100644 --- a/DockerFiles/master_server.yml +++ b/DockerFiles/master_server.yml @@ -13,6 +13,7 @@ services: - 5432:5432 volumes: - ./.db:/var/lib/postgresql/data + - ../src/libtrader/db/sql:/docker-entrypoint-initdb.d/ adminer: container_name: pt_admin image: adminer diff --git a/src/libtrader/db/sql/000_table_companies.sql b/src/libtrader/db/sql/000_table_companies.sql index ef71f8b..4c30725 100644 --- a/src/libtrader/db/sql/000_table_companies.sql +++ b/src/libtrader/db/sql/000_table_companies.sql @@ -1,11 +1,11 @@ CREATE TABLE companies ( - id BIGSERIAL PRIMARY KEY - symbol text UNIQUE NOT NULL - isin text UNIQUE NOT NULL - company_name text NOT NULL - primary_exchange text NOT NULL - sector text NOT NULL - industry text NOT NULL - primary_sic_code text NOT NULL + id BIGSERIAL PRIMARY KEY, + symbol text UNIQUE NOT NULL, + isin text UNIQUE NOT NULL, + company_name text NOT NULL, + primary_exchange text NOT NULL, + sector text NOT NULL, + industry text NOT NULL, + primary_sic_code text NOT NULL, employees bigint NOT NULL ) diff --git a/src/libtrader/db/sql/002_table_stock.sql b/src/libtrader/db/sql/002_table_stock.sql index f4d6578..7d3497a 100644 --- a/src/libtrader/db/sql/002_table_stock.sql +++ b/src/libtrader/db/sql/002_table_stock.sql @@ -1,8 +1,8 @@ CREATE TABLE asset_schema.stock_vals ( - id BIGSERIAL PRIMARY KEY - isin text NOT NULL - time_since_epoch timestamp NOT NULL - ask_price numeric NOT NULL - bid_price numeric NOT NULL + id BIGSERIAL PRIMARY KEY, + isin text NOT NULL, + time_since_epoch timestamp NOT NULL, + ask_price numeric NOT NULL, + bid_price numeric NOT NULL, volume bigint NOT NULL ) diff --git a/src/libtrader/db/sql/004_table_sessions.sql b/src/libtrader/db/sql/004_table_sessions.sql index 259f07e..3077a4e 100644 --- a/src/libtrader/db/sql/004_table_sessions.sql +++ b/src/libtrader/db/sql/004_table_sessions.sql @@ -1,6 +1,6 @@ CREATE TABLE sessions_schema.sessions ( - sess_id text NOT NULL - client_ip text NOT NULL - expiry_date timestamp NOT NULL + sess_id text NOT NULL, + client_ip text NOT NULL, + expiry_date timestamp NOT NULL, is_active bool NOT NULL )