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/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..d68ce93 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -20,16 +20,27 @@ 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
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
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..9ffb40d
--- /dev/null
+++ b/src/main/resources/db/mariadb/migration/V0__initial.sql
@@ -0,0 +1,12 @@
+CREATE TABLE enrollment_requests
+(
+ id BIGINT PRIMARY KEY AUTO_INCREMENT,
+ 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..03a702d
--- /dev/null
+++ b/src/main/resources/db/mariadb/migration/V4__add_associations.sql
@@ -0,0 +1,8 @@
+CREATE TABLE associations
+(
+ 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,
+ 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