4 Commits

Author SHA1 Message Date
Hanbin Lee
7b5135c109 [#38] feat: 정리
- flyway README 파일 따로 구성
- flyway 관련 기존 gradle 설정 제거
- Jenkinsfile 내용 복구 및 리팩토링
2023-03-12 19:42:06 +09:00
Hanbin Lee
2c93cc3dd2 [#38] feat: feature/33 내용 merge 2023-03-12 19:24:00 +09:00
Hanbin Lee
be217c6b01 Merge branch 'feature/33' into feature/38 2023-03-12 19:23:27 +09:00
Hanbin Lee
e9115e5322 Merge pull request #37 from beaniejoy/feature/33
Jenkins Pipeline에 flyway migration 단계 추가 적용
2023-03-04 00:38:03 +09:00
9 changed files with 48 additions and 72 deletions

View File

@@ -19,6 +19,7 @@ pipeline {
flywayCommand: 'info migrate validate',
commandLineArgs: "-configFiles=${FLYWAY_CONFIG}",
credentialsId: 'ecb29499-7272-4e8b-b3ab-a7a3ab7eafab',
url: '',
locations: "filesystem:${WORKSPACE}/db/migration"
}
}

View File

@@ -5,7 +5,7 @@
<br>
## Specification
## :pushpin: Specification
- Lang
- java 17
- kotlin 1.6.21
@@ -33,7 +33,7 @@
<br>
## :pushpin: Run Application
## :pushpin: Setting
### 💽 로컬 DB 구성 (docker)
- local에 DB(MySQL)용 docker container run
@@ -42,31 +42,8 @@
$ docker run --name mysql-server -e MYSQL_ROOT_PASSWORD=beaniejoy -d -p 3306:3306 mysql:8.0.21
```
### 💽 DB Migration (flyway)
[flyway doc](https://documentation.red-gate.com/fd/flyway-documentation-138346877.html)
- **Info**
Prints the details and status information about all the migrations
```bash
$ ./gradlew :db:flywayInfo
```
- **Validate**
Validates the applied migrations against the available ones
DB에 적용된 migration과 local에 적용된 migration 정보 일치 여부 체크
```bash
$ ./gradlew :db:flywayValidate
```
- **Migrate**
Migrates the schema to the latest version
migration 설정 내용들 반영
```bash
$ ./gradlew :db:flywayMigrate
```
- **Clean**
Drops all objects (tables, views, procedures, triggers, …) in the configured schemas
(prodution 단계에서는 절대 사용 X)
```bash
$ ./gradlew :db:flywayClean -i
```
### 💽 DB Migration (with flyway)
- [DB migration directory README](https://github.com/beaniejoy/dongne-cafe-api/blob/main/db/README.md)
### 💽 docker compose 실행(수정 작업 진행중)
- docker compose를 이용한 nginx, DB(MySQL), application 한꺼번에 실행하는 경우

View File

@@ -15,8 +15,4 @@ object Plugins {
const val PLUGIN_SPRING = "plugin.spring"
const val PLUGIN_JPA = "plugin.jpa"
}
object FlywayDB {
const val FLYWAY = "org.flywaydb.flyway"
}
}

View File

@@ -15,8 +15,4 @@ object Version {
const val KOTLIN_LOGGING = "3.0.4"
const val JWT = "0.11.5"
}
object FlywayDB {
const val FLYWAY_CORE = "9.8.1"
}
}

42
db/README.md Normal file
View File

@@ -0,0 +1,42 @@
# DB Migration
- flyway version: `9.15.4`
- [flyway doc](https://documentation.red-gate.com/fd/flyway-documentation-138346877.html)
## :pushpin: Installation
```shell
$ brew install flyway
```
- macOS 전용
<br>
## :pushpin: Flyway Command
- **Clean**
Drops all objects (tables, views, procedures, triggers, …) in the configured schemas
(prodution 단계에서는 절대 사용 X)
```bash
$ flyway clean -configFiles=db/flyway.conf
```
- **Info**
Prints the details and status information about all the migrations
```bash
$ flyway info -configFiles=db/flyway.conf
```
- **Migrate**
Migrates the schema to the latest version
migration 설정 내용들 반영
```bash
$ flyway migrate -configFiles=db/flyway.conf
```
- **Validate**
Validates the applied migrations against the available ones
DB에 적용된 migration과 local에 적용된 migration 정보 일치 여부 체크
```bash
$ flyway validate -configFiles=db/flyway.conf
```

View File

@@ -1,25 +0,0 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.flywaydb:flyway-mysql:${Version.FlywayDB.FLYWAY_CORE}")
}
}
plugins {
id(Plugins.FlywayDB.FLYWAY).version(Version.FlywayDB.FLYWAY_CORE)
}
dependencies {
implementation("org.flywaydb:flyway-core:${Version.FlywayDB.FLYWAY_CORE}") // flyway
}
flyway {
baselineDescription = "Start Flyway Migration!"
baselineOnMigrate = true
baselineVersion = "000"
configFiles = arrayOf(System.getProperty("config") ?: "flyway.conf")
cleanDisabled = false // activate flywayClean
ignoreMigrationPatterns = arrayOf("*:pending") // ignore validating pending(대기) state
}

View File

@@ -5,7 +5,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
ddl-auto: none # use [service-api] flyway migration
ddl-auto: none # use flyway migration
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5InnoDBDialect

View File

@@ -1,10 +0,0 @@
#!/bin/bash
echo "================ 1. Flyway Info ================"
./gradlew :db:flywayInfo -Dconfig=$1
echo "================ 2. Flyway Validate ============"
./gradlew :db:flywayValidate -Dconfig=$1
echo "================ 3. Flyway Migrate ============="
./gradlew :db:flywayMigrate -Dconfig=$1

View File

@@ -2,4 +2,3 @@ rootProject.name = "dongne-cafe-api"
include("dongne-common")
include("dongne-service-api")
include("dongne-account-api")
include("db")