Skip to content

Commit

Permalink
refs #8 flywayを導入
Browse files Browse the repository at this point in the history
  • Loading branch information
averak committed Jan 8, 2024
1 parent d67c25a commit 957cd28
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {

alias(libs.plugins.versions)
alias(libs.plugins.version.catalog.update)
alias(libs.plugins.flyway)
alias(libs.plugins.gradle.git.properties)
alias(libs.plugins.spotless)
alias(libs.plugins.sonarqube)
Expand All @@ -16,6 +17,7 @@ plugins {
buildscript {
dependencies {
classpath(libs.spring.boot.gradle.plugin)
classpath(libs.flyway.gradle.plugin)
}
}

Expand Down Expand Up @@ -203,6 +205,8 @@ dependencies {
implementation(libs.spring.boot.starter)
implementation(libs.spring.boot.starter.data.jpa)
implementation(libs.google.cloud.spanner.jdbc)
implementation(libs.flyway.core)
implementation(libs.flyway.spanner)
}

gitProperties {
Expand Down
5 changes: 5 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[versions]
easy-random = "6.2.1"
flyway = "10.4.1"
groovy = "4.0.7"
kotlin = "1.9.20"
spock = "2.4-M1-groovy-4.0"
Expand All @@ -8,6 +9,9 @@ spring-boot = "3.2.1"
[libraries]
commons-lang3 = "org.apache.commons:commons-lang3:3.13.0"
easy-random = { module = "io.github.dvgaba:easy-random-core", version.ref = "easy-random" }
flyway-core = { module = "org.flywaydb:flyway-core", version.ref = "flyway" }
flyway-spanner = { module = "org.flywaydb:flyway-gcp-spanner", version.ref = "flyway" }
flyway-gradle-plugin = { module = "org.flywaydb:flyway-gradle-plugin", version.ref = "flyway" }
groovy = { module = "org.apache.groovy:groovy", version.ref = "groovy" }
groovy-sql = { module = "org.apache.groovy:groovy-sql", version.ref = "groovy" }
guava = "com.google.guava:guava:32.1.3-jre"
Expand All @@ -29,6 +33,7 @@ google-cloud-spanner-jdbc = "com.google.cloud:google-cloud-spanner-jdbc:2.15.0"
google-cloud-spanner-hibernate = "com.google.cloud:google-cloud-spanner-hibernate-dialect:3.0.3"

[plugins]
flyway = { id = "org.flywaydb.flyway", version.ref = "flyway" }
gradle-git-properties = "com.gorylenko.gradle-git-properties:2.4.1"
sonarqube = "org.sonarqube:4.4.1.3373"
spotless = "com.diffplug.spotless:6.22.0"
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ spring:
time-zone: UTC
main:
allow-bean-definition-overriding: true
flyway:
url: ${spring.datasource.url}
driver-class-name: ${spring.datasource.driver-class-name}
enabled: true
baseline-on-migrate: true
validate-on-migrate: false
outOfOrder: false
locations: classpath:/migration
connect-retries: 5

server:
port: ${PORT:8080}
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/migration/V1_0_0_0__init_schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
START BATCH DDL;

CREATE TABLE echo
(
id STRING(36) NOT NULL,
message STRING(255) NOT NULL,
timestamp TIMESTAMP NOT NULL,
) PRIMARY KEY (id);

RUN BATCH;

0 comments on commit 957cd28

Please sign in to comment.