Skip to content

Commit

Permalink
[chore] #115 DB 스키마 변경에 따른 script 수정 2
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeesw committed Aug 25, 2024
1 parent 1579475 commit 26f415f
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 55 deletions.
19 changes: 10 additions & 9 deletions src/main/resources/sql/data.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
-- 장르 초기화 (한국십진분류법(KDC) 6판 기준)
USE booktalk;
CREATE TABLE IF NOT EXISTS genre (
genre_id bigint auto_increment
primary key,
kdc_num varchar(255) null,
name varchar(255) null,
parent_genre_id bigint null,
constraint FKroi0p36nixht1l7b3hadih34l
foreign key (parent_genre_id) references genre (genre_id)
)engine=InnoDB DEFAULT CHARSET=utf8; #한글 인코딩
CREATE TABLE IF NOT EXISTS genre
(
genre_id bigint auto_increment
primary key,
parent_genre_id bigint null,
kdc_num varchar(255) null,
name varchar(255) null,
constraint FKroi0p36nixht1l7b3hadih34l
foreign key (parent_genre_id) references genre (genre_id)
);

INSERT IGNORE INTO genre (parent_genre_id, kdc_num, name)
values
Expand Down
111 changes: 65 additions & 46 deletions src/main/resources/sql/dummy.sql
Original file line number Diff line number Diff line change
@@ -1,76 +1,95 @@
USE booktalk;
CREATE TABLE IF NOT EXISTS book
USE booktalk;
CREATE TABLE IF NOT EXISTS user
(
book_id bigint auto_increment
birth_date date null,
gender tinyint null,
reg_date datetime(6) null,
user_id bigint auto_increment
primary key,
isbn varchar(255) null,
genre_id bigint null,
constraint FK2wrw92qged8jq0ucjtt972pbc
foreign key (genre_id) references genre (genre_id)
apple_id varchar(255) null,
kakao_id varchar(255) null,
nickname varchar(255) null,
constraint UK792t1v1e9f43yusiryq37re13
unique (kakao_id),
constraint UKah2bnumq4fnjg70axxky0j5xs
unique (nickname),
constraint UKmnjg735lsf6wola6yyxxfj08l
unique (apple_id),
check (`gender` between 0 and 2)
);
CREATE TABLE IF NOT EXISTS book
(
book_id bigint auto_increment
primary key,
isbn varchar(255) null
);
CREATE TABLE IF NOT EXISTS opentalk
(
book_id bigint not null,
opentalk_id bigint auto_increment
primary key,
book_id bigint not null,
constraint UK2xjdoiqspesxa8oenlmyt52us
unique (book_id),
constraint FK3v2bbp8k2bt96wybtbk6pv9yp
foreign key (book_id) references book (book_id)
);
CREATE TABLE IF NOT EXISTS user
(
user_id bigint auto_increment
primary key,
birth_date date null,
gender tinyint null,
kakao_id varchar(255) null,
login_id varchar(255) null,
nickname varchar(255) null,
password varchar(255) null,
reg_date datetime(6) null,
email varchar(255) null,
phone varchar(255) null,
apple_id varchar(255) null,
profile_image varchar(255) null,
profile_image_url varchar(255) null,
constraint UK792t1v1e9f43yusiryq37re13
unique (kakao_id),
constraint UKmnjg735lsf6wola6yyxxfj08l
unique (apple_id),
constraint UKns0jdvuknugj5tmxq82un8q1x
unique (login_id),
check (`gender` between 0 and 2)
);
CREATE TABLE IF NOT EXISTS user_opentalk
CREATE TABLE IF NOT EXISTS message
(
user_opentalk_id bigint auto_increment
created_at datetime(6) null,
message_id bigint auto_increment
primary key,
opentalk_id bigint null,
user_id bigint null,
content varchar(255) null,
constraint FK1iwnhnomrpim1phe1x0qlnva7
foreign key (opentalk_id) references opentalk (opentalk_id),
constraint FK2op594yomeg261726h4dj75jq
foreign key (user_id) references user (user_id)
);
create index idx_message_createdAt
on message (created_at);
CREATE TABLE IF NOT EXISTS `user dibs_books`
(
user_id bigint not null,
book_imageurl varchar(255) null,
bookname varchar(255) null,
isbn varchar(255) null,
constraint FKjhhvi9pyxkt4w4ysu9o0b858x
foreign key (user_id) references user (user_id)
);

CREATE TABLE IF NOT EXISTS user_libraries
(
user_id bigint not null,
code varchar(255) null,
name varchar(255) null,
constraint FKcgk06cv5efj863hr3ffsa45r4
foreign key (user_id) references user (user_id)
);
CREATE TABLE IF NOT EXISTS user_opentalk
(
opentalk_id bigint null,
user_id bigint null,
user_opentalk_id bigint auto_increment
primary key,
constraint FK1klbjl6843fae6vli3yu88s0a
foreign key (opentalk_id) references opentalk (opentalk_id),
constraint FKhri45w7pin1p8n1drbpiy0bgh
foreign key (user_id) references user (user_id)
);
CREATE TABLE IF NOT EXISTS message
CREATE TABLE IF NOT EXISTS user_read_books
(
message_id bigint auto_increment
primary key,
content varchar(255) null,
created_at datetime(6) null,
opentalk_id bigint null,
user_id bigint null,
image_url varchar(255) null,
constraint FK1iwnhnomrpim1phe1x0qlnva7
foreign key (opentalk_id) references opentalk (opentalk_id),
constraint FK2op594yomeg261726h4dj75jq
user_id bigint not null,
book_imageurl varchar(255) null,
bookname varchar(255) null,
isbn varchar(255) null,
constraint FKks39a5vkr0flfyih9t7qpl88n
foreign key (user_id) references user (user_id)
);



INSERT IGNORE INTO book (book_id, isbn)
INSERT IGNORE INTO book (book_id, isbn)
VALUES (1, '9788956055466'),
(2, '9788994120966'),
(3, '9788936433673'),
Expand Down

0 comments on commit 26f415f

Please sign in to comment.