Skip to content

Commit

Permalink
Merge pull request #3 from NAGAZA-Team/fix/flyway
Browse files Browse the repository at this point in the history
  • Loading branch information
HyungJu authored Apr 1, 2024
2 parents 331acd2 + 9fe8133 commit 7aec1ce
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 278 deletions.
164 changes: 95 additions & 69 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,100 +1,126 @@
import org.flywaydb.gradle.task.FlywayMigrateTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.1.3"
kotlin("jvm") version "1.8.22"
kotlin("plugin.spring") version "1.8.22"
kotlin("plugin.jpa") version "1.8.22"
kotlin("kapt") version "1.8.22"
id("com.google.cloud.tools.jib") version "3.3.2"
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.1.3"
kotlin("jvm") version "1.8.22"
kotlin("plugin.spring") version "1.8.22"
kotlin("plugin.jpa") version "1.8.22"
kotlin("kapt") version "1.8.22"
id("com.google.cloud.tools.jib") version "3.3.2"
id("co.uzzu.dotenv.gradle") version "4.0.0"
id("org.flywaydb.flyway") version "10.9.1"
}

group = "kr.nagaza"
version = "0.0.1"

java {
sourceCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {

// Web Related Dependencies
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("com.nimbusds:nimbus-jose-jwt:9.37")
implementation("io.jsonwebtoken:jjwt-api:0.11.5")
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.5")
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.5")

// Database Related Dependencies
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.flywaydb:flyway-core")
implementation("org.flywaydb:flyway-mysql")
runtimeOnly("com.mysql:mysql-connector-j")
implementation("com.querydsl:querydsl-jpa:5.0.0:jakarta")
kapt("com.querydsl:querydsl-apt:5.0.0:jakarta")
kapt("com.querydsl:querydsl-kotlin-codegen:5.0.0")

// Test Related Dependencies
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.mockito:mockito-core:5.6.0")
testImplementation("org.mockito:mockito-junit-jupiter:5.6.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0")

// Extra Utility Dependencies
implementation("com.github.f4b6a3:ulid-creator:5.2.0")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
// Web Related Dependencies
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("com.nimbusds:nimbus-jose-jwt:9.37")
implementation("io.jsonwebtoken:jjwt-api:0.11.5")
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.5")
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.5")

// Database Related Dependencies
implementation("org.springframework.boot:spring-boot-starter-data-jpa")

compileOnly("org.flywaydb:flyway-mysql")
implementation("org.flywaydb:flyway-core")
runtimeOnly("com.mysql:mysql-connector-j")

implementation("com.querydsl:querydsl-jpa:5.0.0:jakarta")
kapt("com.querydsl:querydsl-apt:5.0.0:jakarta")
kapt("com.querydsl:querydsl-kotlin-codegen:5.0.0")

// Test Related Dependencies
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.mockito:mockito-core:5.6.0")
testImplementation("org.mockito:mockito-junit-jupiter:5.6.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0")

// Extra Utility Dependencies
implementation("com.github.f4b6a3:ulid-creator:5.2.0")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
}

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.flywaydb:flyway-mysql:10.10.0")
}
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "17"
}
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "17"
}
}

tasks.withType<Test> {
useJUnitPlatform()
useJUnitPlatform()
}

val activeProfile: String? = System.getProperty("spring.profiles.active")
val repoURL: String? = System.getProperty("imageName")
val imageTag: String? = System.getProperty("imageTag")

jib {
from {
image = "amazoncorretto:17-alpine3.17-jdk"
}
to {
image = repoURL
tags = setOf(imageTag)
}
container {
jvmFlags = listOf(
"-Dspring.profiles.active=${activeProfile}",
"-Dserver.port=8080",
"-Djava.security.egd=file:/dev/./urandom",
"-Dfile.encoding=UTF-8",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseContainerSupport",
"-XX:+UseG1GC",
"-XX:InitialHeapSize=2g",
"-XX:MaxHeapSize=2g",
"-XX:+DisableExplicitGC", //System.gc() 방어
"-server",
)
ports = listOf("8080")
}
from {
image = "amazoncorretto:17-alpine3.17-jdk"
}
to {
image = repoURL
tags = setOf(imageTag)
}
container {
jvmFlags =
listOf(
"-Dspring.profiles.active=$activeProfile",
"-Dserver.port=8080",
"-Djava.security.egd=file:/dev/./urandom",
"-Dfile.encoding=UTF-8",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseContainerSupport",
"-XX:+UseG1GC",
"-XX:InitialHeapSize=2g",
"-XX:MaxHeapSize=2g",
"-XX:+DisableExplicitGC", // System.gc() 방어
"-server",
)
ports = listOf("8080")
}
}

flyway {
url = env.MYSQL_URL.value + "?permitMysqlScheme=true"
user = env.MYSQL_USERNAME.value
password = env.MYSQL_PASSWORD.value
locations = arrayOf("classpath:db/migration")
driver = "com.mysql.cj.jdbc.Driver"
}

tasks.withType<FlywayMigrateTask> {
dependsOn("classes")
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,56 @@ class CafeEntity(
@Id
@Column(name = "cafe_id")
val cafeId: String,

@Column(name = "franchise_id")
@Column(name = "franchise_id", nullable = false)
val franchiseId: String,

@Column(name = "cafe_name")
@Column(name = "cafe_name", nullable = false)
val cafeName: String,

@Column(name = "description")
@Column(name = "description", nullable = false)
val description: String,

@Column(name = "address")
val address: String?,

@Column(name = "web_url")
val webUrl: String?,

@Column(name = "phone_number")
val phoneNumber: String?,

@Column(name = "location_lat")
val locationLat: Double?,

@Column(name = "location_lng")
val locationLng: Double?,

@Column(name = "addr_1")
val addressOne: String?,

@Column(name = "addr_2")
val addressTwo: String?,
) {
fun toModel() = Cafe(
id = cafeId,
franchiseId = franchiseId,
name = cafeName,
description = description,
address = address,
webUrl = webUrl,
phoneNumber = phoneNumber,
locationLat = locationLat,
locationLng = locationLng,
addressOne = addressOne,
addressTwo = addressTwo,
)
fun toModel() =
Cafe(
id = cafeId,
franchiseId = franchiseId,
name = cafeName,
description = description,
address = address,
webUrl = webUrl,
phoneNumber = phoneNumber,
locationLat = locationLat,
locationLng = locationLng,
addressOne = addressOne,
addressTwo = addressTwo,
)

companion object {
fun fromModel(cafe: Cafe) = CafeEntity(
cafeId = cafe.id,
franchiseId = cafe.franchiseId,
cafeName = cafe.name,
description = cafe.description,
address = cafe.address,
webUrl = cafe.webUrl,
phoneNumber = cafe.phoneNumber,
locationLat = cafe.locationLat,
locationLng = cafe.locationLng,
addressOne = cafe.addressOne,
addressTwo = cafe.addressTwo,
)
fun fromModel(cafe: Cafe) =
CafeEntity(
cafeId = cafe.id,
franchiseId = cafe.franchiseId,
cafeName = cafe.name,
description = cafe.description,
address = cafe.address,
webUrl = cafe.webUrl,
phoneNumber = cafe.phoneNumber,
locationLat = cafe.locationLat,
locationLng = cafe.locationLng,
addressOne = cafe.addressOne,
addressTwo = cafe.addressTwo,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class CafeRoomEntity(
@Id
@Column(name = "room_id")
val roomId: String,
@Column(name = "cafe_id")
@Column(name = "cafe_id", nullable = false)
val cafeId: String,
@Column(name = "title")
@Column(name = "title", nullable = false)
val title: String,
@Column(name = "description")
@Column(name = "description", nullable = false)
val description: String,
@ManyToMany
@JoinTable(
Expand All @@ -23,9 +23,9 @@ class CafeRoomEntity(
inverseJoinColumns = [JoinColumn(name = "genre_id")],
)
val genre: MutableSet<GenreEntity> = mutableSetOf(),
@Column(name = "timeout")
@Column(name = "timeout", nullable = false)
val timeout: Int,
@Column(name = "recommend_user")
@Column(name = "recommend_user", nullable = false)
val recommendUserCnt: Int,
@Column(name = "room_img_url")
val roomImgUrl: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ class CafeRoomReviewDetailEntity(
@Id
@Column(name = "review_id")
val reviewId: String,
@Column(name = "user_cnt")
@Column(name = "user_cnt", nullable = false)
val userCnt: Int,
@Column(name = "is_cleared")
@Column(name = "is_cleared", nullable = false)
val isCleared: Boolean,
@Column(name = "is_life_theme")
@Column(name = "is_life_theme", nullable = false)
val isLifeTheme: Boolean,
@Column(name = "used_hint_cnt")
@Column(name = "used_hint_cnt", nullable = false)
val usedHintCnt: Int,
@Column(name = "content")
@Column(name = "content", nullable = false)
val content: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ class CafeRoomReviewEntity(
@Id
@Column(name = "review_id")
val reviewId: String,
@Column(name = "room_id")
@Column(name = "room_id", nullable = false)
val roomId: String,
@Column(name = "user_id")
@Column(name = "user_id", nullable = false)
val userId: String,
@OneToOne
@PrimaryKeyJoinColumn
val detail: CafeRoomReviewDetailEntity,
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "review_id")
val ratingFields: List<CafeRoomReviewRatingFieldEntity> = listOf(),
@Column(name = "created_at")
@Column(name = "created_at", nullable = false)
val createdAt: Date,
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class CafeRoomReviewRatingFieldEntity(
@Id
@Column(name = "rating_field_id")
val ratingFieldId: String,
@Column(name = "review_id")
@Column(name = "review_id", nullable = false)
val reviewId: String,
@Column(name = "type")
@Column(name = "type", nullable = false)
val fieldType: RatingFieldType,
@Column(name = "value")
@Column(name = "value", nullable = false)
val value: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GenreEntity(
@Id
@Column(name = "genre_id")
val genreId: String,
@Column(name = "name")
@Column(name = "name", nullable = false)
val name: String,
) {
fun toModel(): Genre {
Expand Down
Loading

0 comments on commit 7aec1ce

Please sign in to comment.