Skip to content

Commit

Permalink
feat: Flyway 마이그레이션 스크립트 추가 (#53)
Browse files Browse the repository at this point in the history
* feat: JPA & DB 프로퍼티 변경

* feat: init DDL 생성
  • Loading branch information
CChuYong authored May 28, 2024
1 parent 2f446a8 commit 1582f9b
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .jpb/jpb-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DatabaseMigrationSettings" lastSelectedDirectory="src/main/resources" />
<component name="PersistenceUnitSettings">
<persistence-units>
<persistence-unit moduleName="depromeet-makers-be.main" name="Default" defaultSearchScope="Project">
<packages>
<package value="com.depromeet.makers" />
</packages>
</persistence-unit>
</persistence-units>
</component>
</project>
54 changes: 54 additions & 0 deletions src/main/resources/V1__init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
CREATE TABLE attendances
(
id CHAR(26) NOT NULL,
generation INT NOT NULL,
week INT NOT NULL,
member_id CHAR(26) NOT NULL,
session_type VARCHAR(255) NOT NULL,
attendance_status VARCHAR(255) NOT NULL,
attendance_time datetime NULL,
CONSTRAINT pk_attendances PRIMARY KEY (id)
);

CREATE TABLE member
(
id CHAR(26) NOT NULL,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
passcord VARCHAR(255) NULL,
CONSTRAINT pk_member PRIMARY KEY (id)
);

CREATE TABLE member_generation
(
member_id CHAR(26) NOT NULL,
generation_id INT NOT NULL,
group_id INT NULL,
`role` VARCHAR(255) NOT NULL,
position VARCHAR(255) NOT NULL,
CONSTRAINT pk_member_generation PRIMARY KEY (member_id, generation_id)
);

CREATE TABLE session
(
id CHAR(26) NOT NULL,
generation INT NOT NULL,
week INT NOT NULL,
title VARCHAR(255) NOT NULL,
`description` VARCHAR(255) NOT NULL,
start_time datetime NOT NULL,
session_type VARCHAR(255) NOT NULL,
address VARCHAR(255) NULL,
longitude DOUBLE NULL,
latitude DOUBLE NULL,
CONSTRAINT pk_session PRIMARY KEY (id)
);

ALTER TABLE member
ADD CONSTRAINT uc_member_email UNIQUE (email);

ALTER TABLE attendances
ADD CONSTRAINT FK_ATTENDANCES_ON_MEMBER FOREIGN KEY (member_id) REFERENCES member (id);

ALTER TABLE member_generation
ADD CONSTRAINT FK_MEMBER_GENERATION_ON_MEMBER FOREIGN KEY (member_id) REFERENCES member (id);
18 changes: 18 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
spring:
jpa:
hibernate:
ddl-auto: validate
show-sql: false
application:
name: depromeet-makers-be
flyway:
enabled: true
baseline-on-migrate: true
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: ${MYSQL_URL}
username: ${MYSQL_USERNAME}
password: ${MYSQL_PASSWORD}
hikari:
auto-commit: false
pool-name: makers-db-pool
minimum-idle: 10
maximum-pool-size: 30
connection-timeout: 60000
data-source-properties:
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true

server:
shutdown: graceful
tomcat:
Expand Down

0 comments on commit 1582f9b

Please sign in to comment.