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")