Skip to content

Commit

Permalink
feat: MYSQL 도커 설정 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
khabh authored Nov 2, 2024
1 parent b6d3708 commit 86a7081
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
36 changes: 36 additions & 0 deletions ticket/docker/db/mysql/init/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
create database if not exists ticket;

use ticket;

create table if not exists member
(
id bigint not null auto_increment,
name varchar(255),
primary key (id)
) engine = InnoDB;

create table if not exists member_ticket
(
id bigint not null auto_increment,
member_id bigint,
ticket_id bigint,
primary key (id)
) engine = InnoDB;

create table if not exists ticket
(
id bigint not null auto_increment,
quantity bigint,
name varchar(255),
primary key (id)
) engine = InnoDB;

alter table member_ticket
add constraint FKomlguxfcardby8919wyyaxcw3
foreign key (member_id)
references member (id);

alter table member_ticket
add constraint FK4ri79r4gubettxo63roi3ksfj
foreign key (ticket_id)
references ticket (id);
17 changes: 17 additions & 0 deletions ticket/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.9"
services:
db:
image: mysql:8.0.28
platform: linux/x86_64
restart: always
ports:
- "13306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ticket
MYSQL_ROOT_USER: root
MYSQL_PASSWORD: root
TZ: Asia/Seoul
volumes:
- ./db/mysql/data:/var/lib/mysql
- ./db/mysql/init/schema.sql:/docker-entrypoint-initdb.d/schema.sql
1 change: 0 additions & 1 deletion ticket/src/main/resources/application.properties

This file was deleted.

14 changes: 14 additions & 0 deletions ticket/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:13306/ticket?useSSL=false&serverTimezone=Asia/Seoul&characterEncoding=UTF-8&allowPublicKeyRetrieval=true
username: root
password: root

jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
format_sql: true
show_sql: true
hbm2ddl.auto: validate

0 comments on commit 86a7081

Please sign in to comment.