Skip to content

Commit 73dd951

Browse files
authored
Refactoring of the DB migration to apply the appropriate migration based on the database dialect. (#18)
* fix(database): add missing dcql script to posgresql migrations * refactor(migration): refactor database configration and migrations to automatilly apply dialect migrations
1 parent 0ce1208 commit 73dd951

20 files changed

+48
-6
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ datasources:
6969
username: superuser
7070
password: superpassword
7171
dialect: POSTGRES
72-
# Update migration scripts location
73-
flyway:
74-
datasources:
75-
default:
76-
locations:
77-
- classpath:db/migration/postgresql
7872

7973
## Usage
8074

src/main/resources/application.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ flyway:
3535
enabled: true
3636
locations:
3737
- classpath:db/migration/common
38+
- classpath:db/migration/${datasources.default.dialect}

src/main/resources/db/migration/common/V0_0_1__initial-migration.sql renamed to src/main/resources/db/migration/H2/V0_0_1__initial-migration.sql

File renamed without changes.

src/main/resources/db/migration/common/V1_0_2__minimal_table.sql renamed to src/main/resources/db/migration/H2/V1_0_2__minimal_table.sql

File renamed without changes.

src/main/resources/db/migration/common/V2_0_0__clean_tables.sql renamed to src/main/resources/db/migration/H2/V2_0_0__clean_tables.sql

File renamed without changes.

src/main/resources/db/migration/common/V2_0_1__add_flat_claim_flag.sql renamed to src/main/resources/db/migration/H2/V2_0_1__add_flat_claim_flag.sql

File renamed without changes.

src/main/resources/db/migration/h2/V2_0_2__add_dcql.sql renamed to src/main/resources/db/migration/H2/V2_0_2__add_dcql.sql

File renamed without changes.

src/main/resources/db/migration/common/V2_0_3__add_authorization_path.sql renamed to src/main/resources/db/migration/H2/V2_0_3__add_authorization_path.sql

File renamed without changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CREATE TABLE IF NOT EXISTS `service` (
2+
`id` varchar(255) NOT NULL PRIMARY KEY
3+
);
4+
5+
CREATE TABLE IF NOT EXISTS `credential` (
6+
`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
7+
`credential_type` varchar(255) NOT NULL,
8+
`service_id` varchar(255) NOT NULL,
9+
CONSTRAINT `fk_service` FOREIGN KEY (`service_id`) REFERENCES `service` (`id`) ON DELETE CASCADE
10+
);
11+
12+
CREATE TABLE IF NOT EXISTS `endpoint_entry` (
13+
`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
14+
`endpoint` varchar(255) NOT NULL,
15+
`type` varchar(100) NOT NULL,
16+
`credential_id` int NOT NULL,
17+
CONSTRAINT `fk_credential` FOREIGN KEY (`credential_id`) REFERENCES `credential` (`id`) ON DELETE CASCADE
18+
);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
DROP TABLE IF EXISTS `endpoint_entry` CASCADE;
2+
DROP TABLE IF EXISTS `credential` CASCADE;
3+
DROP TABLE IF EXISTS `service` CASCADE;
4+
5+
CREATE TABLE IF NOT EXISTS `service` (
6+
`id` varchar(255) NOT NULL PRIMARY KEY,
7+
`default_oidc_scope` varchar(255) NOT NULL,
8+
`oidc_scopes` LONGTEXT NOT NULL
9+
);

0 commit comments

Comments
 (0)