From 7b5135c10913bf764df80e974e8639a1e1e4da48 Mon Sep 17 00:00:00 2001 From: Hanbin Lee Date: Sun, 12 Mar 2023 19:42:06 +0900 Subject: [PATCH] =?UTF-8?q?[#38]=20feat:=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - flyway README 파일 따로 구성 - flyway 관련 기존 gradle 설정 제거 - Jenkinsfile 내용 복구 및 리팩토링 --- README.md | 31 ++------------ buildSrc/src/main/kotlin/Plugins.kt | 4 -- buildSrc/src/main/kotlin/Version.kt | 4 -- db/README.md | 42 +++++++++++++++++++ db/build.gradle.kts | 25 ----------- .../src/main/resources/application.yml | 2 +- script/db_migration.sh | 10 ----- settings.gradle.kts | 1 - 8 files changed, 47 insertions(+), 72 deletions(-) create mode 100644 db/README.md delete mode 100644 db/build.gradle.kts delete mode 100644 script/db_migration.sh diff --git a/README.md b/README.md index c3b38a1..e071829 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@
-## Specification +## :pushpin: Specification - Lang - java 17 - kotlin 1.6.21 @@ -33,7 +33,7 @@
-## :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 한꺼번에 실행하는 경우 diff --git a/buildSrc/src/main/kotlin/Plugins.kt b/buildSrc/src/main/kotlin/Plugins.kt index fc50b9f..d2efd40 100644 --- a/buildSrc/src/main/kotlin/Plugins.kt +++ b/buildSrc/src/main/kotlin/Plugins.kt @@ -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" - } } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Version.kt b/buildSrc/src/main/kotlin/Version.kt index 7dec8b7..dcae670 100644 --- a/buildSrc/src/main/kotlin/Version.kt +++ b/buildSrc/src/main/kotlin/Version.kt @@ -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" - } } \ No newline at end of file diff --git a/db/README.md b/db/README.md new file mode 100644 index 0000000..425f954 --- /dev/null +++ b/db/README.md @@ -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 전용 + +
+ +## :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 +``` \ No newline at end of file diff --git a/db/build.gradle.kts b/db/build.gradle.kts deleted file mode 100644 index 7415256..0000000 --- a/db/build.gradle.kts +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/dongne-account-api/src/main/resources/application.yml b/dongne-account-api/src/main/resources/application.yml index 91aa6e4..438f753 100644 --- a/dongne-account-api/src/main/resources/application.yml +++ b/dongne-account-api/src/main/resources/application.yml @@ -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 diff --git a/script/db_migration.sh b/script/db_migration.sh deleted file mode 100644 index 6ba1373..0000000 --- a/script/db_migration.sh +++ /dev/null @@ -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 diff --git a/settings.gradle.kts b/settings.gradle.kts index 0b593f1..a1387d1 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,4 +2,3 @@ rootProject.name = "dongne-cafe-api" include("dongne-common") include("dongne-service-api") include("dongne-account-api") -include("db")