Skip to content

Commit

Permalink
[FR-#4.0] Add docker.yaml && sql files for initial DB version
Browse files Browse the repository at this point in the history
  • Loading branch information
IThror10 committed Feb 13, 2024
1 parent fcaaa74 commit c33e74b
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3"

services:
data-base:
image: postgres
restart: unless-stopped
environment:
- POSTGRES_DB=rpa-DB
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_MAX_CONNECTIONS=2000
ports:
- "7777:5432"
volumes:
- ./modules/harmonist/src/main/sql/create_database.sql:/docker-entrypoint-initdb.d/01_init.sql
- ./modules/harmonist/src/main/sql/insert_database.sql:/docker-entrypoint-initdb.d/02_insert_values.sql
20 changes: 20 additions & 0 deletions modules/harmonist/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
spring:
application:
name: rpa
datasource:
url: jdbc:postgresql://localhost:7777/rpa-DB
driverClassName: org.postgresql.Driver
username: postgres
password: postgres
jpa:
show-sql: true
hibernate:
ddl-auto: update
springdoc:
swagger-ui:
path: /swagger/src
api-docs:
path: /swagger/docs
token:
signing:
key: 53A73E5F1C4E0A2D3B5F2D784E6A1B423D6F247D1F6E5C3A596D635A75327855
60 changes: 60 additions & 0 deletions modules/harmonist/src/main/sql/create_database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
CREATE TABLE IF NOT EXISTS users (
id serial PRIMARY KEY,
nickname varchar NOT NULL UNIQUE,
email varchar NOT NULL UNIQUE,
password varchar NOT NULL,
phone varchar NULL UNIQUE,
role varchar NOT NULL DEFAULT ('user')
);

CREATE TABLE IF NOT EXISTS groups (
id serial PRIMARY KEY,
leader integer REFERENCES users (id),
name varchar NOT NULL UNIQUE,
description text NOT NULL
);

CREATE TABLE IF NOT EXISTS participants (
user_id integer REFERENCES users (id),
group_id integer REFERENCES groups (id),
status integer NOT NULL,

PRIMARY KEY (user_id, group_id)
);


CREATE TABLE IF NOT EXISTS scripts (
id serial PRIMARY KEY,
code text NOT NULL,
name varchar NOT NULL,
description text NOT NULL,
input_data jsonb NOT NULL,

version varchar NOT NULL,
created timestamp,
creator integer REFERENCES users (id)
);

CREATE TABLE IF NOT EXISTS authors (
user_id integer REFERENCES users (id),
script_id integer REFERENCES scripts (id),

PRIMARY KEY (user_id, script_id)
);

CREATE TABLE IF NOT EXISTS executors (
group_id integer REFERENCES groups (id),
script_id integer REFERENCES scripts (id),

PRIMARY KEY (group_id, script_id)
);

CREATE TABLE IF NOT EXISTS actions (
user_id integer REFERENCES users (id),
script_id integer REFERENCES scripts (id),
time_begin timestamp NOT NULL,
time_exec timestamp DEFAULT (NULL),
input_data varchar NULL,

PRIMARY KEY (user_id, script_id, time_begin, time_exec)
);
13 changes: 13 additions & 0 deletions modules/harmonist/src/main/sql/insert_database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
INSERT INTO users (nickname, email, password, phone)
VALUES ('IThror', '[email protected]', '12345', '8-800'),
('Alien', '[email protected]', 'qwerty', '8-700'),
('Tutor', '[email protected]', '1q2w3e', '8-600');

INSERT INTO groups (leader, name, description)
VALUES (1, 'Itmo SE Students', '2023/2025 Itmo SE Students group'),
(3, 'Itmo SE Tutors', 'ITMO SE Tutors');

INSERT INTO participants (user_id, group_id, status)
VALUES (1, 1, 0), -- Editor
(2, 1, 1), -- User
(3, 2, 0);

0 comments on commit c33e74b

Please sign in to comment.