Browse Source

FLOWER-2491 liquibase 프로파일 별로 동작하게 수정

develop
bean 2 years ago
parent
commit
00e6c6d05d
  1. 8
      README.md
  2. 50
      build.gradle.kts
  3. 0
      src/main/resources/liquibase/postgres/dev.yaml
  4. 0
      src/main/resources/liquibase/postgres/prod.yaml
  5. 0
      src/main/resources/postgres/stage.yaml

8
README.md

@ -8,7 +8,7 @@
### feature 브랜치 생성
- gitflow 방식에 의해 develop 브랜치로부터 feature 브랜치 생성
- feature 브랜치 명명 규칙: `feature/(postgres | assign-redshift | device-redshift)-v<MAJOR_VERSION_NUMBER>[-<MINOR_VERSION_NUMBER>]`
- feature 브랜치 명명 규칙: `feature/postgres-v<MAJOR_VERSION_NUMBER>[-<MINOR_VERSION_NUMBER>]`
- `v` 는 소문자
- changelog 버젼 충동을 방지하기 위함
- 명명 규칙에 의거하여 리모트 레파지토리에 먼저 올린 브랜치가 버젼 선점에 대한 우선권을 갖습니다.
@ -24,7 +24,7 @@
### changelog 파일 생성하거나 generate 된 파일 변경
- 위치: `src/main/resources/(postgres | assign-redshift | device-redshift)/changelog`
- 위치: `src/main/resources/postgres/changelog`
- 파일 형식: `v<MAJOR_VERSION_NUMBER>[.<MINOR_VERSION_NUMBER>]__(ddl | dml)__<NAME>.yaml`
- `v` 는 소문자
- `_` 가 2개임
@ -47,7 +47,7 @@
### apm-stage 에 반영
```shell
./gradlew update --db (postgres | assign-redshift | device-redshift) --profile apm-dev
./gradlew update --profile apm-dev
```
### 운영 반영
@ -55,7 +55,7 @@
1. release/hotfix 브랜치 생성
1. 반영
```shell
./gradlew update --db (postgres | assign-redshift | device-redshift) --profile (skb-prod | uplus-prod | flower-prod)
./gradlew update --profile (skb-prod | uplus-prod | flower-prod)
```
1. changelog 파일에 태그 달기(운영 작업 후 필수)
* major version: 테이블을 추가하거나 삭제한 경우 major version 을 올린다.

50
build.gradle.kts

@ -29,18 +29,13 @@ dependencies {
liquibaseRuntime("org.liquibase:liquibase-core")
liquibaseRuntime("org.liquibase.ext:liquibase-hibernate6:4.25.1")
liquibaseRuntime("info.picocli:picocli:4.6.3")
liquibaseRuntime("com.h2database:h2")
liquibaseRuntime("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
liquibase {
activities.register("postgres") {
this.arguments = mapOf("changeLogFile" to "src/main/resources/postgres/dev.yaml")
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
@ -51,3 +46,46 @@ tasks.withType<KotlinCompile> {
tasks.withType<Test> {
useJUnitPlatform()
}
liquibase {
val profile = System.getProperty("profile") ?: "local"
// TODO: db.yaml objectMapper 로 읽어서 세팅?
activities.register("local") {
this.arguments = mapOf(
"url" to "jdbc:postgresql://localhost:15432/localdb",
"username" to "flower",
"password" to "flower"
)
}
activities.register("dev") {
this.arguments = mapOf(
"url" to "jdbc:postgresql://flower-fragrance-stage.cluster-cbth1bnhfbdg.ap-northeast-2.rds.amazonaws.com:5432/devdb",
"username" to "anypoint",
"password" to "*emflaj*"
)
}
runList = profile
}
fun addArguments(name: String, args: Map<String, String>) {
val activity = liquibase.activities.getByName(name)
activity.name = name
val activityArgs = activity.arguments as Map<*, *>
val newArgs = mutableMapOf<String, String>()
newArgs.putAll(activityArgs.map { it.key as String to it.value as String })
newArgs.putAll(args)
newArgs.forEach {
println("arguments[\"${it.key}\"]=\"${it.value}\"")
}
activity.arguments = newArgs
}
tasks.getByName("generateChangelog").doFirst {
val changeLogFile = "src/main/resources/liquibase/postgres/changelog/generated.yaml"
delete(changeLogFile)
val name = System.getProperty("name") ?: "local"
addArguments(name, mapOf("changeLogFile" to changeLogFile))
}

0
src/main/resources/postgres/dev.yaml → src/main/resources/liquibase/postgres/dev.yaml

0
src/main/resources/postgres/prod.yaml → src/main/resources/liquibase/postgres/prod.yaml

0
src/main/resources/postgres/stage.yaml

Loading…
Cancel
Save