From eda5f227d8f1de324c95f7946a7ced6f420307c1 Mon Sep 17 00:00:00 2001 From: Matheus Horstmann <mch15@inf.ufpr.br> Date: Fri, 22 Feb 2019 16:19:17 -0300 Subject: [PATCH] Issue #2: Integrate psql-manager and create dummies data Signed-off-by: Matheus Horstmann <mch15@inf.ufpr.br> --- .gitignore | 7 +++++ .gitlab-ci.yml | 28 +++++++++++++++++++ .gitmodules | 3 ++ psql-manager | 1 + workspace/create/00-core-tables.sql | 24 ++++++---------- workspace/fixture/form.csv | 3 ++ workspace/fixture/form_answer.csv | 6 ++++ workspace/fixture/input.csv | 7 +++++ workspace/fixture/input_answer.csv | 14 ++++++++++ workspace/fixture/input_validation.csv | 8 ++++++ .../fixture/input_validation_argument.csv | 4 +++ 11 files changed, 89 insertions(+), 16 deletions(-) create mode 100644 .gitignore create mode 100644 .gitlab-ci.yml create mode 100644 .gitmodules create mode 160000 psql-manager create mode 100644 workspace/fixture/form.csv create mode 100644 workspace/fixture/form_answer.csv create mode 100644 workspace/fixture/input.csv create mode 100644 workspace/fixture/input_answer.csv create mode 100644 workspace/fixture/input_validation.csv create mode 100644 workspace/fixture/input_validation_argument.csv diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4258fb1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.in +*.out +*.swp +*.swo +*.tmp +docker-compose.yml +.env diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..5ab842c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,28 @@ +image: debian:stretch + +services: + - "postgres:10" + +variables: + POSTGRES_DB: 'postgres' + POSTGRES_USER: 'postgres' + PGPASSWORD: 'postgres' + POSTGRES_HOST: 'postgres' + GIT_SUBMODULE_STRATEGY: normal + +stages: + - test +run_test: + stage: test + script: + - apt-get update -q -y + - apt-get install wget gnupg -y + - echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list + - wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - + - apt-get update -q -y + - apt-get install -y postgresql-client-10 + - ./psql-manager/manager.sh create ./workspace/ + - ./psql-manager/manager.sh fixture ./workspace/ + tags: + - debian + - postgres diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8d2eeed --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "psql-manager"] + path = psql-manager + url = https://gitlab.c3sl.ufpr.br/c3sl/psql-manager.git diff --git a/psql-manager b/psql-manager new file mode 160000 index 0000000..fe2cedf --- /dev/null +++ b/psql-manager @@ -0,0 +1 @@ +Subproject commit fe2cedf1403a91b9779cafa3fb5fc7288f5a017b diff --git a/workspace/create/00-core-tables.sql b/workspace/create/00-core-tables.sql index 974588f..451b87b 100644 --- a/workspace/create/00-core-tables.sql +++ b/workspace/create/00-core-tables.sql @@ -1,19 +1,12 @@ CREATE TABLE form ( id SERIAL PRIMARY KEY, - latest_version INTEGER -); - -CREATE TABLE form_version ( - id SERIAL PRIMARY KEY, - id_form INTEGER, - version INTEGER, title TEXT, description TEXT -); +); CREATE TABLE input ( id SERIAL PRIMARY KEY, - id_form_version INTEGER, + id_form INTEGER, placement INTEGER, input_type TEXT, question TEXT, @@ -23,26 +16,25 @@ CREATE TABLE input ( CREATE TABLE input_validation ( id SERIAL PRIMARY KEY, id_input INTEGER, - validation_type TEXT, - argument_number INTEGER + validation_type TEXT ); CREATE TABLE input_validation_argument ( id SERIAL PRIMARY KEY, id_input_validation INTEGER, placement INTEGER, - argument TEXT, + argument TEXT ); -CREATE TABLE form_version_answer ( +CREATE TABLE form_answer ( id SERIAL PRIMARY KEY, - id_form_version INTEGER, - timestamp TIMESTAMP + id_form INTEGER, + answered_at TIMESTAMP ); CREATE TABLE input_answer ( id SERIAL PRIMARY KEY, - id_form_version_answer INTEGER, + id_form_answer INTEGER, id_input INTEGER, value TEXT, placement TEXT diff --git a/workspace/fixture/form.csv b/workspace/fixture/form.csv new file mode 100644 index 0000000..9b0bd12 --- /dev/null +++ b/workspace/fixture/form.csv @@ -0,0 +1,3 @@ +1;'Form Title 1'; 'Form Description 1' +2;'Form Title 2'; 'Form Description 2' +3;'Form Title 3'; 'Form Description 3' diff --git a/workspace/fixture/form_answer.csv b/workspace/fixture/form_answer.csv new file mode 100644 index 0000000..bd53037 --- /dev/null +++ b/workspace/fixture/form_answer.csv @@ -0,0 +1,6 @@ +1; 3; '2018-06-02 10:10:25-03' +2; 2; '2019-01-12 11:10:25-03' +3; 1; '2019-02-21 12:10:25-03' +4; 2; '2017-06-15 13:10:25-03' +5; 3; '2018-12-31 23:59:59-03' +6; 1; '2019-01-22 19:10:25-03' diff --git a/workspace/fixture/input.csv b/workspace/fixture/input.csv new file mode 100644 index 0000000..3615a98 --- /dev/null +++ b/workspace/fixture/input.csv @@ -0,0 +1,7 @@ +1; 1; 1; 'TEXT'; 'Question 1 Form 1';'Description Question 1 Form 1' +2; 1; 2; 'TEXT'; 'Question 2 Form 1';'Description Question 2 Form 1' +3; 1; 3; 'TEXT'; 'Question 3 Form 1';'Description Question 3 Form 1' +4; 2; 2; 'TEXT'; 'Question 2 Form 2';'Description Question 2 Form 2' +5; 2; 1; 'TEXT'; 'Question 1 Form 2';'Description Question 1 Form 2' +6; 3; 1; 'TEXT'; 'Question 1 Form 3';'Description Question 1 Form 3' +7; 3; 2; 'TEXT'; 'Question 2 Form 3';'Description Question 2 Form 3' diff --git a/workspace/fixture/input_answer.csv b/workspace/fixture/input_answer.csv new file mode 100644 index 0000000..4ebb0c3 --- /dev/null +++ b/workspace/fixture/input_answer.csv @@ -0,0 +1,14 @@ +1; 1; 6; 'Answer to Question 1 Form 3'; 1 +2; 1; 7; 'Answer to Question 2 Form 3'; 2 +3; 2; 4; 'Answer to Question 2 Form 2'; 2 +4; 2; 5; 'Answer to Question 1 Form 2'; 1 +5; 3; 1; 'Answer to Question 1 Form 1'; 1 +6; 3; 2; 'Answer to Question 2 Form 1'; 2 +7; 3; 3; 'Answer to Question 3 Form 1'; 3 +8; 4; 4; 'Answer to Question 2 Form 2'; 2 +9; 4; 5; 'Answer to Question 1 Form 2'; 1 +10; 5; 6; 'Answer to Question 1 Form 3'; 1 +11; 5; 7; 'Answer to Question 2 Form 3'; 2 +12; 6; 1; 'Answer to Question 1 Form 1'; 1 +13; 6; 2; 'Answer to Question 2 Form 1'; 2 +14; 6; 3; 'Answer to Question 3 Form 1'; 3 diff --git a/workspace/fixture/input_validation.csv b/workspace/fixture/input_validation.csv new file mode 100644 index 0000000..2650619 --- /dev/null +++ b/workspace/fixture/input_validation.csv @@ -0,0 +1,8 @@ +1;2; 'REGEX' +2;3; 'MAXCHAR' +3;4; 'MINCHAR' +4;5; 'MANDATORY' +5;6; 'MANDATORY' +6;7; 'MANDATORY' +7;2; 'MANDATORY' +8;3; 'MINCHAR' diff --git a/workspace/fixture/input_validation_argument.csv b/workspace/fixture/input_validation_argument.csv new file mode 100644 index 0000000..121fb14 --- /dev/null +++ b/workspace/fixture/input_validation_argument.csv @@ -0,0 +1,4 @@ +1; 1; 1; '\\d{5}-\\d{3}' +2; 2; 1; '10' +3; 3; 1; '2' +4; 3; 2; '8' -- GitLab