Skip to content

Commit

Permalink
refactor: db migration mysql to postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
gimhanul committed Nov 11, 2023
1 parent b77d0d0 commit 1bb7c3b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:3.1.4'
runtimeOnly 'org.postgresql:postgresql'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
Expand Down
17 changes: 6 additions & 11 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
version: '3'

services:
mysql:
postgresql:
container_name: simblue.local.db
image: mysql/mysql-server:5.7
image: postgres:15-alpine
environment:
MYSQL_ROOT_HOST: "%"
MYSQL_USER: "soolung"
MYSQL_PASSWORD: "soolung"
MYSQL_DATABASE: "soolung_simblue"
POSTGRES_USER: "soolung"
POSTGRES_PASSWORD: "soolung"
POSTGRES_DB: "soolung_simblue"
ports:
- "3307:3306"
command:
- "mysqld"
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"
- "5432:5432"

redis:
image: redis:7.0-alpine
Expand Down
17 changes: 7 additions & 10 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,22 @@ spring:
matching-strategy: ant_path_matcher

jpa:
database: mysql
database-platform: org.hibernate.dialect.MySQL8Dialect
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
database: postgresql
database-platform: org.hibernate.dialect.PostgreSQLDialect

generate-ddl: true
hibernate:
ddl-auto: validate

datasource:
url: jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
driver-class-name: org.postgresql.Driver
username: ${DB_USERNAME}
password: ${DB_PASSWORD}

redis:
host: ${REDIS_HOST}
port: 6379
port: ${REDIS_PORT}
password: ${REDIS_PASSWORD}

cache:
Expand Down Expand Up @@ -94,8 +91,8 @@ spring:
ddl-auto: update

datasource:
url: jdbc:mysql://127.0.0.1:3307/soolung_simblue
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:postgresql://127.0.0.1:5432/soolung_simblue
driver-class-name: org.postgresql.Driver
username: soolung
password: soolung

Expand Down

0 comments on commit 1bb7c3b

Please sign in to comment.