diff --git a/build.gradle b/build.gradle index 02e38663..a19b379b 100644 --- a/build.gradle +++ b/build.gradle @@ -41,6 +41,9 @@ dependencies { // MySQL runtimeOnly 'com.mysql:mysql-connector-j' + implementation 'org.flywaydb:flyway-core' + implementation 'org.flywaydb:flyway-mysql' + // jwt implementation 'io.jsonwebtoken:jjwt:0.9.1' @@ -55,6 +58,7 @@ dependencies { testRuntimeOnly 'org.junit.platform:junit-platform-launcher' testImplementation 'io.rest-assured:rest-assured' + } tasks.named('test') { diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 7c7409e1..e8692abd 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,16 +1,26 @@ spring: + h2: + console: + enabled: true + path: /h2-console datasource: - url: jdbc:mysql://localhost:3306/nexters - username: test - password: test + url: jdbc:h2:~/test;MODE=MYSQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE; + username: sa jpa: database-platform: org.hibernate.dialect.MySQLDialect hibernate: - ddl-auto: update + ddl-auto: validate data: redis: host: localhost port: 6379 + flyway: + enabled: true + baseline-on-migrate: true + url: jdbc:mysql://localhost:3306/nexters + user: test + password: test + baseline-version: 0 jwt: secret: ${JWT_SECRET} diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index de85fc78..548cf2aa 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -4,20 +4,30 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver username: ${DB_USERNAME} password: ${DB_PASSWORD} + jpa: database-platform: org.hibernate.dialect.MySQLDialect hibernate: - ddl-auto: update + ddl-auto: validate properties: hibernate: format_sql: true show-sql: false open-in-view: false + data: redis: host: ${REDIS_HOST} port: 6379 + flyway: + enabled: true + baseline-on-migrate: true + url: jdbc:mysql://${DB_HOSTNAME}:${DB_PORT}/${DB_DATABASE} + user: ${DB_USERNAME} + password: ${DB_PASSWORD} + baseline-version: 0 + jwt: secret: ${JWT_SECRET} access-token: @@ -34,4 +44,5 @@ springdoc: oauth: apple: iss: https://appleid.apple.com - client-id: ${OAUTH_APPLE_CLIENT_ID} \ No newline at end of file + client-id: ${OAUTH_APPLE_CLIENT_ID} + diff --git a/src/main/resources/db/migration/V1__init.sql b/src/main/resources/db/migration/V1__init.sql new file mode 100644 index 00000000..308ed384 --- /dev/null +++ b/src/main/resources/db/migration/V1__init.sql @@ -0,0 +1,33 @@ +create table if not exists nexters.member +( + member_id bigint auto_increment + primary key, + created_at datetime(6) null, + deleted_at datetime(6) null, + updated_at datetime(6) null, + character_type varchar(255) null, + email varchar(255) not null, + nickname varchar(255) null, + social_id varchar(255) null, + social_type varchar(255) null, + constraint uk_member__social_id + unique (social_id) +); + +create table if not exists nexters.mission +( + mission_id bigint auto_increment + primary key, + created_at datetime(6) null, + deleted_at datetime(6) null, + updated_at datetime(6) null, + board_count int not null, + description varchar(255) not null, + host_member_id bigint not null, + invitation_code varchar(255) not null, + mission_day varchar(255) not null, + mission_end_date datetime(6) not null, + mission_start_date datetime(6) not null, + upload_end_time varchar(255) not null, + upload_start_time varchar(255) not null +); \ No newline at end of file