Skip to content

Commit

Permalink
Merge pull request #82 from gooormmoon/feat/game/GRTEAM-10/immyeong
Browse files Browse the repository at this point in the history
fix: db utf8 encoding
  • Loading branch information
sshinylee authored Jun 23, 2024
2 parents 8e4af04 + e17c2cb commit d6fc350
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions algofi-mysql/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ FROM mysql:oraclelinux9
# 이 디렉토리에 파일을 넣으면 MySQL이 자동으로 이 설정 파일을 읽게 됩니다.
#COPY ./config/mysql.cnf /etc/my.cnf
#RUN chmod 644 /etc/my.cnf
COPY ./config/mysql.cnf /etc/my.cnf.d/my.cnf
RUN chmod 644 /etc/my.cnf.d/my.cnf
COPY ./config/mysql.cnf /etc/my.cnf
RUN chmod 644 /etc/my.cnf

# init 파일을 /docker-entrypoint-initdb.d/로 복사
# 이 디렉토리에 있는 SQL 스크립트는 컨테이너가 처음 실행 시 자동 실행됨
Expand Down
9 changes: 6 additions & 3 deletions algofi-mysql/config/mysql.cnf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[mysqld]
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql
socket=/var/run/mysqld/mysqld.sock
secure-file-priv=/var/lib/mysql-files
user=mysql
pid-file=/var/run/mysqld/mysqld.pid
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
collation-server=utf8mb4_0900_ai_ci
init_connect='SET NAMES utf8mb4'

[client]
socket=/var/run/mysqld/mysqld.sock
Expand All @@ -16,4 +16,7 @@ default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4

!includedir /etc/mysql/conf.d/
[mysqldump]
default-character-set=utf8mb4

!includedir /etc/mysql/conf.d/
24 changes: 13 additions & 11 deletions algofi-mysql/init/create_table.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ALTER DATABASE mydb DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
/* member table 생성 */
CREATE TABLE member (
member_id INT(11) AUTO_INCREMENT PRIMARY KEY,
Expand All @@ -12,7 +13,7 @@ CREATE TABLE member (
login_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
created_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
) character set utf8mb4 collate utf8mb4_general_ci;

/* filestorage table 생성 */
CREATE TABLE filestorage (
Expand All @@ -22,7 +23,8 @@ CREATE TABLE filestorage (
created_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_time TIMESTAMP,
FOREIGN KEY(member_id) REFERENCES member(member_id)
);
) character set utf8mb4 collate utf8mb4_general_ci;


/* file table 생성 */
CREATE TABLE file (
Expand All @@ -36,7 +38,7 @@ CREATE TABLE file (
parent_id INT NULL,
FOREIGN KEY(file_storage_id) REFERENCES filestorage(file_storage_id),
FOREIGN KEY(parent_id) REFERENCES file(file_id) ON DELETE CASCADE
);
) character set utf8mb4 collate utf8mb4_general_ci;

/* algorithmproblem table 생성 */
CREATE TABLE algorithmproblem (
Expand All @@ -45,13 +47,13 @@ CREATE TABLE algorithmproblem (
level VARCHAR(10) NOT NULL,
content TEXT,
recommend_time INT
);
) character set utf8mb4 collate utf8mb4_general_ci;

/* chatroom table 생성 */
CREATE TABLE chatroom (
chatroom_id VARCHAR(36) PRIMARY KEY,
chatroom_name VARCHAR(100)
);
) character set utf8mb4 collate utf8mb4_general_ci;

/* message table 생성 */
CREATE TABLE message (
Expand All @@ -63,15 +65,15 @@ CREATE TABLE message (
chatroom_id VARCHAR(36) NOT NULL,
FOREIGN KEY(sender_id) REFERENCES member(member_id),
FOREIGN KEY(chatroom_id) REFERENCES chatroom(chatroom_id)
);
) character set utf8mb4 collate utf8mb4_general_ci;

/* member_chatroom table 생성 */
CREATE TABLE member_chatroom (
chatroom_id VARCHAR(36) NOT NULL,
member_id INT NULL,
FOREIGN KEY(chatroom_id) REFERENCES chatroom(chatroom_id),
FOREIGN KEY(member_id) REFERENCES member(member_id)
);
FOREIGN KEY(member_id) REFERENCES member(member_id)
) character set utf8mb4 collate utf8mb4_general_ci;

/* gameresult table 생성 */
CREATE TABLE gameresult (
Expand All @@ -84,15 +86,15 @@ CREATE TABLE gameresult (
chatroom_id VARCHAR(36) NOT NULL,
FOREIGN KEY (algorithmproblem_id) REFERENCES algorithmproblem(algorithmproblem_id),
FOREIGN KEY (chatroom_id) REFERENCES chatroom(chatroom_id)
);
) character set utf8mb4 collate utf8mb4_general_ci;

/* member_gameresult table 생성 */
CREATE TABLE member_gameresult (
game_result_id INT NOT NULL,
member_id INT NOT NULL,
FOREIGN KEY(game_result_id) REFERENCES gameresult(game_result_id),
FOREIGN KEY(member_id) REFERENCES member(member_id)
);
) character set utf8mb4 collate utf8mb4_general_ci;

/* testcase table 생성 */
CREATE TABLE testcase (
Expand All @@ -101,4 +103,4 @@ CREATE TABLE testcase (
test_output VARCHAR(500),
algorithmproblem_id INT NOT NULL,
FOREIGN KEY(algorithmproblem_id) REFERENCES algorithmproblem(algorithmproblem_id)
);
) character set utf8mb4 collate utf8mb4_general_ci;

0 comments on commit d6fc350

Please sign in to comment.