Skip to content

Commit

Permalink
hotfix: schema, item 등록
Browse files Browse the repository at this point in the history
  • Loading branch information
Shin-Jae-Yoon committed Nov 28, 2023
1 parent 448dc45 commit e144759
Show file tree
Hide file tree
Showing 2 changed files with 286 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/main/resources/sql/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
insert into item (type, category, name, awake_image, sleep_image, unlock_level, created_at)
values ('MORNING', 'SKIN', '오목눈이알', 'https://image.moabam.com/moabam/skins/omok/default/egg.png',
'https://image.moabam.com/moabam/skins/omok/default/egg.png', 0, current_time());

insert into item (type, category, name, awake_image, sleep_image, unlock_level, created_at)
values ('NIGHT', 'SKIN', '부엉이알', 'https://image.moabam.com/moabam/skins/owl/default/egg.png',
'https://image.moabam.com/moabam/skins/owl/default/egg.png', 0, current_time());

insert into item (type, category, name, awake_image, sleep_image, unlock_level, created_at)
values ('MORNING', 'SKIN', '오목눈이', 'https://image.moabam.com/moabam/skins/omok/default/eyes-opened.png',
'https://image.moabam.com/moabam/skins/omok/default/eyes-closed.png', 1, current_time());

insert into item (type, category, name, awake_image, sleep_image, unlock_level, created_at)
values ('MORNING', 'SKIN', '부엉이', 'https://image.moabam.com/moabam/skins/owl/default/eyes-opened.png',
'https://image.moabam.com/moabam/skins/owl/default/eyes-closed.png', 1, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '안경 오목눈이', 'https://image.moabam.com/moabam/skins/omok/glasses/eyes-opened.png',
'https://image.moabam.com/moabam/skins/omok/glasses/eyes-closed', 10, 5, 5, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '안경 부엉이', 'https://image.moabam.com/moabam/skins/owl/glasses/eyes-opened.png',
'https://image.moabam.com/moabam/skins/owl/glasses/eyes-closed', 10, 5, 5, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '목도리 오목눈이', 'https://image.moabam.com/moabam/skins/omok/scarf/eyes-opened.png',
'https://image.moabam.com/moabam/skins/omok/scarf/eyes-closed', 20, 10, 10, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '목도리 부엉이', 'https://image.moabam.com/moabam/skins/owl/scarf/eyes-opened.png',
'https://image.moabam.com/moabam/skins/owl/scarf/eyes-closed', 20, 10, 10, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '산타 오목눈이', 'https://image.moabam.com/moabam/skins/omok/scarf/eyes-opened.png',
'https://image.moabam.com/moabam/skins/omok/scarf/eyes-closed', 30, 15, 15, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '산타 부엉이', 'https://image.moabam.com/moabam/skins/owl/santa/eyes-opened.png',
'https://image.moabam.com/moabam/skins/owl/santa/eyes-closed', 30, 15, 15, current_time());
247 changes: 247 additions & 0 deletions src/main/resources/sql/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
use moabam;

create table badge
(
id bigint not null auto_increment,
member_id bigint not null,
type enum ('MORNING_ADULT','MORNING_BIRTH','NIGHT_ADULT','NIGHT_BIRTH') not null,
created_at datetime(6) not null,
primary key (id)
);

create table bug_history
(
id bigint not null auto_increment,
member_id bigint not null,
payment_id bigint,
bug_type enum ('GOLDEN','MORNING','NIGHT') not null,
action_type enum ('CHARGE','COUPON','REFUND','REWARD','USE') not null,
quantity integer not null,
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

create table certification
(
id bigint not null auto_increment,
routine_id bigint not null,
member_id bigint not null,
image varchar(255) not null,
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

create table coupon
(
id bigint not null auto_increment,
name varchar(20) not null unique,
point integer default 1 not null,
description varchar(50) default '',
type enum ('DISCOUNT','GOLDEN','MORNING','NIGHT') not null,
stock integer default 1 not null,
start_at date not null unique,
open_at date not null,
admin_id bigint not null,
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

create table coupon_wallet
(
id bigint not null auto_increment,
member_id bigint not null,
coupon_id bigint not null,
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

create table daily_member_certification
(
id bigint not null auto_increment,
member_id bigint not null,
room_id bigint not null,
participant_id bigint,
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

create table daily_room_certification
(
id bigint not null auto_increment,
room_id bigint not null,
certified_at date not null,
primary key (id)
);

create table inventory
(
id bigint not null auto_increment,
member_id bigint not null,
item_id bigint not null,
is_default bit default false not null,
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id),
index idx_member_id (member_id)
);

create table item
(
id bigint not null auto_increment,
type enum ('MORNING','NIGHT') not null,
category enum ('SKIN') not null,
name varchar(255) not null,
awake_image varchar(255) not null,
sleep_image varchar(255) not null,
bug_price integer default 0 not null,
golden_bug_price integer default 0 not null,
unlock_level integer default 1 not null,
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

create table member
(
id bigint not null auto_increment,
social_id varchar(255) not null unique,
nickname varchar(255) not null unique,
intro varchar(30),
profile_image varchar(255) not null,
morning_image varchar(255) not null,
night_image varchar(255) not null,
total_certify_count bigint default 0 not null,
report_count integer default 0 not null,
current_morning_count integer default 0 not null,
current_night_count integer default 0 not null,
morning_bug integer default 0 not null,
night_bug integer default 0 not null,
golden_bug integer default 0 not null,
role enum ('ADMIN','BLACK','USER') default 'USER' not null,
deleted_at datetime(6),
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

create table participant
(
id bigint not null auto_increment,
room_id bigint,
member_id bigint not null,
is_manager bit,
certify_count integer,
deleted_at datetime(6),
deleted_room_title varchar(30),
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

create table payment
(
id bigint not null auto_increment,
member_id bigint not null,
product_id bigint not null,
coupon_wallet_id bigint,
order_id varchar(255),
order_name varchar(255) not null,
total_amount integer not null,
discount_amount integer not null,
payment_key varchar(255),
status enum ('ABORTED','CANCELED','DONE','EXPIRED','IN_PROGRESS','READY') not null,
created_at datetime(6) not null,
requested_at datetime(6),
approved_at datetime(6),
primary key (id),
index idx_order_id (order_id)
);

create table product
(
id bigint not null auto_increment,
type enum ('BUG') default 'BUG' not null,
name varchar(255) not null,
price integer not null,
quantity integer default 1 not null,
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

create table report
(
id bigint not null auto_increment,
reporter_id bigint not null,
reported_member_id bigint not null,
room_id bigint,
certification_id bigint,
description varchar(255),
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

create table room
(
id bigint not null auto_increment,
title varchar(20) not null,
password varchar(8),
level integer default 0 not null,
exp integer default 0 not null,
room_type enum ('MORNING','NIGHT'),
certify_time integer not null,
current_user_count integer not null,
max_user_count integer not null,
announcement varchar(100),
room_image varchar(500),
manager_nickname varchar(30),
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

create table routine
(
id bigint not null auto_increment,
room_id bigint,
content varchar(20) not null,
created_at datetime(6) not null,
updated_at datetime(6),
primary key (id)
);

alter table bug_history
add foreign key (payment_id) references payment (id);

alter table certification
add foreign key (routine_id) references routine (id);

alter table coupon_wallet
add foreign key (coupon_id) references coupon (id);

alter table daily_member_certification
add foreign key (participant_id) references participant (id);

alter table inventory
add foreign key (item_id) references item (id);

alter table participant
add foreign key (room_id) references room (id);

alter table payment
add foreign key (product_id) references product (id);

alter table report
add foreign key (certification_id) references certification (id);

alter table report
add foreign key (room_id) references room (id);

alter table routine
add foreign key (room_id) references room (id);

0 comments on commit e144759

Please sign in to comment.