From fd45ab2ca8d0229003ec4ae899e0ecd2b7d939d4 Mon Sep 17 00:00:00 2001 From: Peter Havekes Date: Mon, 13 May 2024 08:38:15 +0200 Subject: [PATCH 1/5] Add support for mariadb --- pom.xml | 6 ++++++ src/main/resources/application.yml | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/pom.xml b/pom.xml index e2829e4..5247112 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,12 @@ 42.6.1 runtime + + + org.mariadb.jdbc + mariadb-java-client + 3.3.3 + org.springframework.boot spring-boot-starter-security diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index cf58462..a596edb 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -24,12 +24,19 @@ spring: dialect: org.hibernate.dialect.H2Dialect open-in-view: false datasource: + ## Default filebased storage driver-class-name: org.h2.Driver url: jdbc:h2:file:./database/student-mobility + ## For Postgress use : # driver-class-name: org.postgresql.Driver # url: jdbc:postgresql://localhost:5432/mobility # username: mobility_rw # password: secret + ## For mariadb use : + # driver-class-name: org.mariadb.jdbc.Driver + # url: jdbc:mariadb://localhost:3306/mobility + # username: mobility_rw + # password: secret flyway: locations: classpath:db/{vendor}/migration From 9650f33c01b1250e8ad181b6ade87dd1f5c400e7 Mon Sep 17 00:00:00 2001 From: Peter Havekes Date: Mon, 13 May 2024 08:44:18 +0200 Subject: [PATCH 2/5] Fix markup --- README.md | 2 +- src/main/resources/application.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9b568f5..4a3c8e7 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/H ## [Building and running](#building-and-running) -### [The student-mobility-inteken-ontvanger-generiek-server](#student-mobility-inteken-ontvanger-generiek-server) +### [The student-mobility-inteken-ontvanger-generiek-server](#the-student-mobility-inteken-ontvanger-generiek-server) This project uses Spring Boot and Maven. To run locally, type: diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a596edb..54cdfa0 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -27,7 +27,7 @@ spring: ## Default filebased storage driver-class-name: org.h2.Driver url: jdbc:h2:file:./database/student-mobility - ## For Postgress use : + ## For Postgress use : # driver-class-name: org.postgresql.Driver # url: jdbc:postgresql://localhost:5432/mobility # username: mobility_rw From a6aa5c0ae19265115a7a11b1d4b8ae1af307a211 Mon Sep 17 00:00:00 2001 From: Peter Havekes Date: Wed, 15 May 2024 09:45:29 +0200 Subject: [PATCH 3/5] Add migrations for mariadb --- .../resources/db/mariadb/migration/V0__initial.sql | 12 ++++++++++++ .../migration/V1__rename_person_id_to_eduid.sql | 1 + .../db/mariadb/migration/V2__add_person_auth.sql | 3 +++ .../mariadb/migration/V3__add_home_institution.sql | 2 ++ .../db/mariadb/migration/V4__add_associations.sql | 8 ++++++++ .../resources/db/mariadb/migration/V5__indexes.sql | 3 +++ 6 files changed, 29 insertions(+) create mode 100644 src/main/resources/db/mariadb/migration/V0__initial.sql create mode 100644 src/main/resources/db/mariadb/migration/V1__rename_person_id_to_eduid.sql create mode 100644 src/main/resources/db/mariadb/migration/V2__add_person_auth.sql create mode 100644 src/main/resources/db/mariadb/migration/V3__add_home_institution.sql create mode 100644 src/main/resources/db/mariadb/migration/V4__add_associations.sql create mode 100644 src/main/resources/db/mariadb/migration/V5__indexes.sql diff --git a/src/main/resources/db/mariadb/migration/V0__initial.sql b/src/main/resources/db/mariadb/migration/V0__initial.sql new file mode 100644 index 0000000..5b7eb6b --- /dev/null +++ b/src/main/resources/db/mariadb/migration/V0__initial.sql @@ -0,0 +1,12 @@ +CREATE TABLE enrollment_requests +( + id BIGINT PRIMARY KEY, + identifier VARCHAR(254) NOT NULL, + person_uri VARCHAR(255) NOT NULL, + results_uri VARCHAR(255) NOT NULL, + person_id VARCHAR(255), + access_token TEXT, + refresh_token TEXT, + scope TEXT NOT NULL, + created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); diff --git a/src/main/resources/db/mariadb/migration/V1__rename_person_id_to_eduid.sql b/src/main/resources/db/mariadb/migration/V1__rename_person_id_to_eduid.sql new file mode 100644 index 0000000..22e5575 --- /dev/null +++ b/src/main/resources/db/mariadb/migration/V1__rename_person_id_to_eduid.sql @@ -0,0 +1 @@ +ALTER TABLE enrollment_requests RENAME COLUMN person_id TO eduid; \ No newline at end of file diff --git a/src/main/resources/db/mariadb/migration/V2__add_person_auth.sql b/src/main/resources/db/mariadb/migration/V2__add_person_auth.sql new file mode 100644 index 0000000..2cb9773 --- /dev/null +++ b/src/main/resources/db/mariadb/migration/V2__add_person_auth.sql @@ -0,0 +1,3 @@ +ALTER TABLE enrollment_requests ADD COLUMN person_auth VARCHAR(255); +UPDATE enrollment_requests set person_auth = 'HEADER'; +ALTER TABLE enrollment_requests MODIFY person_auth VARCHAR(255) NOT NULL; diff --git a/src/main/resources/db/mariadb/migration/V3__add_home_institution.sql b/src/main/resources/db/mariadb/migration/V3__add_home_institution.sql new file mode 100644 index 0000000..ad124ed --- /dev/null +++ b/src/main/resources/db/mariadb/migration/V3__add_home_institution.sql @@ -0,0 +1,2 @@ +ALTER TABLE enrollment_requests ADD COLUMN home_institution VARCHAR(255); +ALTER TABLE enrollment_requests DROP COLUMN results_uri; diff --git a/src/main/resources/db/mariadb/migration/V4__add_associations.sql b/src/main/resources/db/mariadb/migration/V4__add_associations.sql new file mode 100644 index 0000000..179e31f --- /dev/null +++ b/src/main/resources/db/mariadb/migration/V4__add_associations.sql @@ -0,0 +1,8 @@ +CREATE TABLE associations +( + id BIGINT PRIMARY KEY, + association_id VARCHAR(254) NOT NULL, + enrollment_request_id BIGINT NOT NULL, + created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT fk_enrollment_request_id FOREIGN KEY (enrollment_request_id) REFERENCES enrollment_requests(id) ON DELETE CASCADE +); diff --git a/src/main/resources/db/mariadb/migration/V5__indexes.sql b/src/main/resources/db/mariadb/migration/V5__indexes.sql new file mode 100644 index 0000000..9f2ce58 --- /dev/null +++ b/src/main/resources/db/mariadb/migration/V5__indexes.sql @@ -0,0 +1,3 @@ +CREATE INDEX association_id_index ON associations(association_id); +CREATE INDEX eduid_index ON enrollment_requests(eduid); +CREATE INDEX identifier_index ON enrollment_requests(identifier); \ No newline at end of file From 2304b10aafed6ec61cae2738f3cd52488a96aaf0 Mon Sep 17 00:00:00 2001 From: Peter Havekes Date: Wed, 15 May 2024 13:19:03 +0200 Subject: [PATCH 4/5] Add AUTO_INCREMENT to madiadb migrations --- src/main/resources/db/mariadb/migration/V0__initial.sql | 2 +- .../resources/db/mariadb/migration/V4__add_associations.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/db/mariadb/migration/V0__initial.sql b/src/main/resources/db/mariadb/migration/V0__initial.sql index 5b7eb6b..9ffb40d 100644 --- a/src/main/resources/db/mariadb/migration/V0__initial.sql +++ b/src/main/resources/db/mariadb/migration/V0__initial.sql @@ -1,6 +1,6 @@ CREATE TABLE enrollment_requests ( - id BIGINT PRIMARY KEY, + id BIGINT PRIMARY KEY AUTO_INCREMENT, identifier VARCHAR(254) NOT NULL, person_uri VARCHAR(255) NOT NULL, results_uri VARCHAR(255) NOT NULL, diff --git a/src/main/resources/db/mariadb/migration/V4__add_associations.sql b/src/main/resources/db/mariadb/migration/V4__add_associations.sql index 179e31f..03a702d 100644 --- a/src/main/resources/db/mariadb/migration/V4__add_associations.sql +++ b/src/main/resources/db/mariadb/migration/V4__add_associations.sql @@ -1,6 +1,6 @@ CREATE TABLE associations ( - id BIGINT PRIMARY KEY, + id BIGINT PRIMARY KEY AUTO_INCREMENT, association_id VARCHAR(254) NOT NULL, enrollment_request_id BIGINT NOT NULL, created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, From cf4ae6e7bfada661bba7ef059b2eda8f06099075 Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Wed, 15 May 2024 13:37:58 +0200 Subject: [PATCH 5/5] Added comment for mariaDB Driver --- src/main/resources/application.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 54cdfa0..d68ce93 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -20,8 +20,12 @@ spring: properties: hibernate: naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy - # dialect: org.hibernate.dialect.PostgreSQL10Dialect + ## Default filebased storage dialect: org.hibernate.dialect.H2Dialect + ## For Postgress use : + # dialect: org.hibernate.dialect.PostgreSQL10Dialect + ## For mariadb use : + # dialect: org.hibernate.dialect.MariaDBDialect open-in-view: false datasource: ## Default filebased storage