diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4258fb13995a0075e4d2d795e0a5cd6b624209a3 --- /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 0000000000000000000000000000000000000000..5ab842cfca75cbba81cd1697dfc5858ab7873bda --- /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 0000000000000000000000000000000000000000..8d2eeed7f5861516c6e8e9af34f580347400ed3e --- /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 0000000000000000000000000000000000000000..fe2cedf1403a91b9779cafa3fb5fc7288f5a017b --- /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 974588fd93db3f7df2262b8417188b500524a9ca..451b87b565d3c7d3b4ece924c31ed784c354e827 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 0000000000000000000000000000000000000000..9b0bd12b1a4cf7f7d2ab8efc90d949abf68b624e --- /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 0000000000000000000000000000000000000000..bd53037a03e0d20328145689feb200e42464bfa8 --- /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 0000000000000000000000000000000000000000..3615a98ddd8b3c9c56eded65ff0f5b57cadd9549 --- /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 0000000000000000000000000000000000000000..4ebb0c3b1bcb4ff99eff25823d036579e94bc058 --- /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 0000000000000000000000000000000000000000..2650619200427e8adf9310faaabc5b9f9d6b44a3 --- /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 0000000000000000000000000000000000000000..121fb14e308afa88f3cb068007e0ed82329e0870 --- /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'