Skip to content

Commit

Permalink
feat(JAQPOT-2): flyway integration (#7)
Browse files Browse the repository at this point in the history
* feat(JAQPOT-2): flyway integration

* feat: add model table creation script

* fix: make openapi work again
  • Loading branch information
alarv authored May 15, 2024
1 parent 6c79496 commit 3d9d4ca
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .jpb/jpb-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DatabaseMigrationSettings" lastSelectedDirectory="src/main/resources/db/migration" flywayMigrationDescription="" useFlywayForce="true" />
<component name="JpaPluginProjectSettings">
<option name="lastSelectedLanguage" value="Kotlin" />
</component>
<component name="PersistenceUnitSettings">
<persistence-units>
<persistence-unit name="Default">
<packages>
<package value="org.jaqpot.api" />
</packages>
</persistence-unit>
</persistence-units>
</component>
</project>
10 changes: 9 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {
id("org.jetbrains.kotlin.plugin.spring") version "1.9.23"

id("org.openapi.generator") version "7.5.0"

id("org.flywaydb.flyway") version "10.13.0"
}

group = "org.jaqpot"
Expand Down Expand Up @@ -50,6 +52,10 @@ dependencies {
compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")

// flyway
implementation("org.flywaydb:flyway-core:10.12.0")
runtimeOnly("org.flywaydb:flyway-database-postgresql:10.12.0")

runtimeOnly("org.postgresql:postgresql")
}

Expand Down Expand Up @@ -89,7 +95,9 @@ openApiGenerate {
sourceSets {
main {
kotlin {
srcDirs("${buildDir}/openapi")
srcDir("${buildDir}/openapi")
}
}
}


10 changes: 9 additions & 1 deletion src/main/kotlin/org/jaqpot/api/config/SecurityConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ class SecurityConfig {
http.authorizeHttpRequests { a ->
a
// allow swagger for everyone
.requestMatchers("/v3/**", "/swagger/**", "/swagger-ui/**", "/models/**").permitAll()
.requestMatchers(
"/", "/swagger-ui.html", "/swagger-ui/**", "/v3/api-docs/**"
)
.permitAll()

.requestMatchers(
"/models/**"
)
.permitAll()

.anyRequest()
.authenticated()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ spring:
url: jdbc:postgresql://localhost:5432/jaqpot
username: user
password: password
driverClassName: org.postgresql.Driver
jpa:
hibernate:
ddl-auto: create-drop
ddl-auto: validate
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
format_sql: true
show-sql: true
security:
oauth2:
resourceserver:
jwt:
issuer-uri: http://localhost:8070/realms/jaqpot-local
flyway:
enabled: true
baseline-on-migrate: true

11 changes: 11 additions & 0 deletions src/main/resources/db/migration/V2__model_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE SEQUENCE IF NOT EXISTS model_seq START WITH 1 INCREMENT BY 50;

CREATE TABLE model
(
id INTEGER NOT NULL,
created_at TIMESTAMP WITHOUT TIME ZONE,
updated_at TIMESTAMP WITHOUT TIME ZONE,
is_public BOOLEAN NOT NULL,
CONSTRAINT pk_model PRIMARY KEY (id)
);

0 comments on commit 3d9d4ca

Please sign in to comment.