Compare commits
4 Commits
feature/33
...
feature/38
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b5135c109 | ||
|
|
2c93cc3dd2 | ||
|
|
be217c6b01 | ||
|
|
e9115e5322 |
@@ -19,6 +19,7 @@ pipeline {
|
|||||||
flywayCommand: 'info migrate validate',
|
flywayCommand: 'info migrate validate',
|
||||||
commandLineArgs: "-configFiles=${FLYWAY_CONFIG}",
|
commandLineArgs: "-configFiles=${FLYWAY_CONFIG}",
|
||||||
credentialsId: 'ecb29499-7272-4e8b-b3ab-a7a3ab7eafab',
|
credentialsId: 'ecb29499-7272-4e8b-b3ab-a7a3ab7eafab',
|
||||||
|
url: '',
|
||||||
locations: "filesystem:${WORKSPACE}/db/migration"
|
locations: "filesystem:${WORKSPACE}/db/migration"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
31
README.md
31
README.md
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Specification
|
## :pushpin: Specification
|
||||||
- Lang
|
- Lang
|
||||||
- java 17
|
- java 17
|
||||||
- kotlin 1.6.21
|
- kotlin 1.6.21
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## :pushpin: Run Application
|
## :pushpin: Setting
|
||||||
|
|
||||||
### 💽 로컬 DB 구성 (docker)
|
### 💽 로컬 DB 구성 (docker)
|
||||||
- local에 DB(MySQL)용 docker container run
|
- 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
|
$ docker run --name mysql-server -e MYSQL_ROOT_PASSWORD=beaniejoy -d -p 3306:3306 mysql:8.0.21
|
||||||
```
|
```
|
||||||
|
|
||||||
### 💽 DB Migration (flyway)
|
### 💽 DB Migration (with flyway)
|
||||||
[flyway doc](https://documentation.red-gate.com/fd/flyway-documentation-138346877.html)
|
- [DB migration directory README](https://github.com/beaniejoy/dongne-cafe-api/blob/main/db/README.md)
|
||||||
- **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
|
|
||||||
```
|
|
||||||
|
|
||||||
### 💽 docker compose 실행(수정 작업 진행중)
|
### 💽 docker compose 실행(수정 작업 진행중)
|
||||||
- docker compose를 이용한 nginx, DB(MySQL), application 한꺼번에 실행하는 경우
|
- docker compose를 이용한 nginx, DB(MySQL), application 한꺼번에 실행하는 경우
|
||||||
|
|||||||
@@ -15,8 +15,4 @@ object Plugins {
|
|||||||
const val PLUGIN_SPRING = "plugin.spring"
|
const val PLUGIN_SPRING = "plugin.spring"
|
||||||
const val PLUGIN_JPA = "plugin.jpa"
|
const val PLUGIN_JPA = "plugin.jpa"
|
||||||
}
|
}
|
||||||
|
|
||||||
object FlywayDB {
|
|
||||||
const val FLYWAY = "org.flywaydb.flyway"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,4 @@ object Version {
|
|||||||
const val KOTLIN_LOGGING = "3.0.4"
|
const val KOTLIN_LOGGING = "3.0.4"
|
||||||
const val JWT = "0.11.5"
|
const val JWT = "0.11.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
object FlywayDB {
|
|
||||||
const val FLYWAY_CORE = "9.8.1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
42
db/README.md
Normal file
42
db/README.md
Normal 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
|
||||||
|
```
|
||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,7 @@ spring:
|
|||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
jpa:
|
jpa:
|
||||||
hibernate:
|
hibernate:
|
||||||
ddl-auto: none # use [service-api] flyway migration
|
ddl-auto: none # use flyway migration
|
||||||
properties:
|
properties:
|
||||||
hibernate:
|
hibernate:
|
||||||
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
|
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -2,4 +2,3 @@ rootProject.name = "dongne-cafe-api"
|
|||||||
include("dongne-common")
|
include("dongne-common")
|
||||||
include("dongne-service-api")
|
include("dongne-service-api")
|
||||||
include("dongne-account-api")
|
include("dongne-account-api")
|
||||||
include("db")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user