generated from pricelees/issue-pr-template
refactor: H2 - MySQL 스키마 통일
This commit is contained in:
parent
f92c82a382
commit
cd3ff32f9f
@ -37,9 +37,9 @@ create table if not exists users(
|
|||||||
phone varchar(20) not null,
|
phone varchar(20) not null,
|
||||||
region_code varchar(10) null,
|
region_code varchar(10) null,
|
||||||
status varchar(20) not null,
|
status varchar(20) not null,
|
||||||
created_at timestamp not null,
|
created_at datetime(6) not null,
|
||||||
created_by bigint not null,
|
created_by bigint not null,
|
||||||
updated_at timestamp not null,
|
updated_at datetime(6) not null,
|
||||||
updated_by bigint not null,
|
updated_by bigint not null,
|
||||||
|
|
||||||
constraint uk__users_email unique (email),
|
constraint uk__users_email unique (email),
|
||||||
@ -52,9 +52,9 @@ create table if not exists user_status_history(
|
|||||||
user_id bigint not null,
|
user_id bigint not null,
|
||||||
status varchar(20) not null,
|
status varchar(20) not null,
|
||||||
reason varchar(255) not null,
|
reason varchar(255) not null,
|
||||||
created_at timestamp not null,
|
created_at datetime(6) not null,
|
||||||
created_by bigint not null,
|
created_by bigint not null,
|
||||||
updated_at timestamp not null,
|
updated_at datetime(6) not null,
|
||||||
updated_by bigint not null,
|
updated_by bigint not null,
|
||||||
|
|
||||||
constraint fk__user_status_history_user_id foreign key (user_id) references users (id)
|
constraint fk__user_status_history_user_id foreign key (user_id) references users (id)
|
||||||
|
|||||||
@ -2,21 +2,31 @@ create table if not exists region (
|
|||||||
code varchar(10) primary key,
|
code varchar(10) primary key,
|
||||||
sido_code varchar(2) not null,
|
sido_code varchar(2) not null,
|
||||||
sigungu_code varchar(3) not null,
|
sigungu_code varchar(3) not null,
|
||||||
dong_code varchar(5) not null ,
|
|
||||||
sido_name varchar(20) not null,
|
sido_name varchar(20) not null,
|
||||||
sigungu_name varchar(20) not null,
|
sigungu_name varchar(20) not null,
|
||||||
dong_name varchar(20) not null
|
|
||||||
|
constraint uk_region__sido_sigungu_code unique (sido_code, sigungu_code)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists members
|
create table if not exists store(
|
||||||
(
|
id bigint primary key,
|
||||||
member_id bigint primary key,
|
name varchar(20) not null,
|
||||||
email varchar(255) not null,
|
address varchar(100) not null,
|
||||||
name varchar(255) not null,
|
contact varchar(50) not null,
|
||||||
password varchar(255) not null,
|
business_reg_num varchar(12) not null,
|
||||||
role varchar(20) not null,
|
region_code varchar(10) not null,
|
||||||
created_at datetime(6) null,
|
status varchar(20) not null,
|
||||||
last_modified_at datetime(6) null
|
|
||||||
|
created_at datetime(6) not null,
|
||||||
|
created_by bigint not null,
|
||||||
|
updated_at datetime(6) not null,
|
||||||
|
updated_by bigint not null,
|
||||||
|
|
||||||
|
constraint uk_store__name unique (name),
|
||||||
|
constraint uk_store__contact unique (contact),
|
||||||
|
constraint uk_store__address unique (address),
|
||||||
|
constraint uk_store__business_reg_num unique (business_reg_num),
|
||||||
|
constraint fk_store__region_code foreign key (region_code) references region (code)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists users(
|
create table if not exists users(
|
||||||
@ -25,7 +35,7 @@ create table if not exists users(
|
|||||||
email varchar(255) not null,
|
email varchar(255) not null,
|
||||||
password varchar(255) not null,
|
password varchar(255) not null,
|
||||||
phone varchar(20) not null,
|
phone varchar(20) not null,
|
||||||
region_code varchar(10) not null,
|
region_code varchar(10) null,
|
||||||
status varchar(20) not null,
|
status varchar(20) not null,
|
||||||
created_at datetime(6) not null,
|
created_at datetime(6) not null,
|
||||||
created_by bigint not null,
|
created_by bigint not null,
|
||||||
@ -56,18 +66,29 @@ create table if not exists admin(
|
|||||||
password varchar(255) not null,
|
password varchar(255) not null,
|
||||||
name varchar(20) not null,
|
name varchar(20) not null,
|
||||||
phone varchar(20) not null,
|
phone varchar(20) not null,
|
||||||
|
type varchar(20) not null,
|
||||||
|
store_id bigint null,
|
||||||
permission_level varchar(20) not null,
|
permission_level varchar(20) not null,
|
||||||
created_at datetime(6) not null,
|
created_at datetime(6) not null,
|
||||||
created_by bigint not null,
|
created_by bigint not null,
|
||||||
updated_at datetime(6) not null,
|
updated_at datetime(6) not null,
|
||||||
updated_by bigint not null
|
updated_by bigint not null,
|
||||||
|
|
||||||
|
constraint uk_admin__account unique (account),
|
||||||
|
constraint uk_admin__phone unique (phone),
|
||||||
|
constraint chk_admin__type check (type in ('HQ', 'STORE')),
|
||||||
|
constraint chk_admin__store_id check (
|
||||||
|
(type = 'HQ' AND store_id IS NULL) OR
|
||||||
|
(type = 'STORE' AND store_id IS NOT NULL)
|
||||||
|
),
|
||||||
|
constraint fk_admin__store_id foreign key (store_id) references store (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists login_history(
|
create table if not exists login_history(
|
||||||
id bigint primary key,
|
id bigint primary key,
|
||||||
principal_id bigint not null,
|
principal_id bigint not null,
|
||||||
principal_type varchar(20) not null,
|
principal_type varchar(20) not null,
|
||||||
success boolean not null,
|
success tinyint(1) not null,
|
||||||
ip_address varchar(45) not null,
|
ip_address varchar(45) not null,
|
||||||
user_agent varchar(255) not null,
|
user_agent varchar(255) not null,
|
||||||
created_at datetime(6) not null
|
created_at datetime(6) not null
|
||||||
@ -85,20 +106,18 @@ create table if not exists theme (
|
|||||||
available_minutes smallint not null,
|
available_minutes smallint not null,
|
||||||
expected_minutes_from smallint not null,
|
expected_minutes_from smallint not null,
|
||||||
expected_minutes_to smallint not null,
|
expected_minutes_to smallint not null,
|
||||||
is_open tinyint(1) not null,
|
is_active tinyint(1) not null,
|
||||||
created_at datetime(6) not null,
|
created_at datetime(6) not null,
|
||||||
created_by bigint not null,
|
created_by bigint not null,
|
||||||
updated_at datetime(6) not null,
|
updated_at datetime(6) not null,
|
||||||
updated_by bigint not null,
|
updated_by bigint not null
|
||||||
|
|
||||||
constraint fk_theme__created_by foreign key (created_by) references members (member_id),
|
|
||||||
constraint fk_theme__updated_by foreign key (updated_by) references members (member_id)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists schedule (
|
create table if not exists schedule (
|
||||||
id bigint primary key,
|
id bigint primary key,
|
||||||
date date not null,
|
date date not null,
|
||||||
time time not null,
|
time time not null,
|
||||||
|
store_id bigint not null,
|
||||||
theme_id bigint not null,
|
theme_id bigint not null,
|
||||||
status varchar(30) not null,
|
status varchar(30) not null,
|
||||||
created_at datetime(6) not null,
|
created_at datetime(6) not null,
|
||||||
@ -106,15 +125,14 @@ create table if not exists schedule (
|
|||||||
updated_at datetime(6) not null,
|
updated_at datetime(6) not null,
|
||||||
updated_by bigint not null,
|
updated_by bigint not null,
|
||||||
|
|
||||||
constraint uk_schedule__date_time_theme_id unique (date, time, theme_id),
|
constraint uk_schedule__store_id_date_time_theme_id unique (store_id, date, time, theme_id),
|
||||||
constraint fk_schedule__created_by foreign key (created_by) references members (member_id),
|
constraint fk_schedule__store_id foreign key (store_id) references store (id),
|
||||||
constraint fk_schedule__updated_by foreign key (updated_by) references members (member_id),
|
|
||||||
constraint fk_schedule__theme_id foreign key (theme_id) references theme (id)
|
constraint fk_schedule__theme_id foreign key (theme_id) references theme (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists reservation (
|
create table if not exists reservation (
|
||||||
id bigint primary key,
|
id bigint primary key,
|
||||||
member_id bigint not null,
|
user_id bigint not null,
|
||||||
schedule_id bigint not null,
|
schedule_id bigint not null,
|
||||||
reserver_name varchar(30) not null,
|
reserver_name varchar(30) not null,
|
||||||
reserver_contact varchar(30) not null,
|
reserver_contact varchar(30) not null,
|
||||||
@ -126,7 +144,7 @@ create table if not exists reservation (
|
|||||||
updated_at datetime(6) not null,
|
updated_at datetime(6) not null,
|
||||||
updated_by bigint not null,
|
updated_by bigint not null,
|
||||||
|
|
||||||
constraint fk_reservation__member_id foreign key (member_id) references members (member_id),
|
constraint fk_reservation__user_id foreign key (user_id) references users (id),
|
||||||
constraint fk_reservation__schedule_id foreign key (schedule_id) references schedule (id)
|
constraint fk_reservation__schedule_id foreign key (schedule_id) references schedule (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -137,13 +155,12 @@ create table if not exists canceled_reservation (
|
|||||||
cancel_reason varchar(50) not null,
|
cancel_reason varchar(50) not null,
|
||||||
canceled_at datetime(6) not null,
|
canceled_at datetime(6) not null,
|
||||||
status varchar(30) not null,
|
status varchar(30) not null,
|
||||||
|
|
||||||
constraint uk_canceled_reservations__reservation_id unique (reservation_id),
|
constraint uk_canceled_reservations__reservation_id unique (reservation_id),
|
||||||
constraint fk_canceled_reservations__reservation_id foreign key (reservation_id) references reservation (id),
|
constraint fk_canceled_reservations__reservation_id foreign key (reservation_id) references reservation (id)
|
||||||
constraint fk_canceled_reservations__canceled_by foreign key (canceled_by) references members (member_id)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists payment
|
create table if not exists payment (
|
||||||
(
|
|
||||||
id bigint primary key,
|
id bigint primary key,
|
||||||
reservation_id bigint not null,
|
reservation_id bigint not null,
|
||||||
type varchar(20) not null,
|
type varchar(20) not null,
|
||||||
@ -153,14 +170,13 @@ create table if not exists payment
|
|||||||
total_amount integer not null,
|
total_amount integer not null,
|
||||||
status varchar(20) not null,
|
status varchar(20) not null,
|
||||||
requested_at datetime(6) not null,
|
requested_at datetime(6) not null,
|
||||||
approved_at datetime(6),
|
approved_at datetime(6) not null,
|
||||||
|
|
||||||
constraint uk_payment__reservationId unique (reservation_id),
|
constraint uk_payment__reservationId unique (reservation_id),
|
||||||
constraint fk_payment__reservationId foreign key (reservation_id) references reservations (reservation_id)
|
constraint fk_payment__reservationId foreign key (reservation_id) references reservation (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists payment_detail
|
create table if not exists payment_detail(
|
||||||
(
|
|
||||||
id bigint primary key,
|
id bigint primary key,
|
||||||
payment_id bigint not null unique,
|
payment_id bigint not null unique,
|
||||||
supplied_amount integer not null,
|
supplied_amount integer not null,
|
||||||
@ -169,8 +185,7 @@ create table if not exists payment_detail
|
|||||||
constraint fk_payment_detail__paymentId foreign key (payment_id) references payment (id)
|
constraint fk_payment_detail__paymentId foreign key (payment_id) references payment (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists payment_bank_transfer_detail
|
create table if not exists payment_bank_transfer_detail (
|
||||||
(
|
|
||||||
id bigint primary key,
|
id bigint primary key,
|
||||||
bank_code varchar(10) not null,
|
bank_code varchar(10) not null,
|
||||||
settlement_status varchar(20) not null,
|
settlement_status varchar(20) not null,
|
||||||
@ -178,8 +193,7 @@ create table if not exists payment_bank_transfer_detail
|
|||||||
constraint fk_payment_bank_transfer_details__id foreign key (id) references payment_detail (id)
|
constraint fk_payment_bank_transfer_details__id foreign key (id) references payment_detail (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists payment_card_detail
|
create table if not exists payment_card_detail (
|
||||||
(
|
|
||||||
id bigint primary key,
|
id bigint primary key,
|
||||||
issuer_code varchar(10) not null,
|
issuer_code varchar(10) not null,
|
||||||
card_type varchar(10) not null,
|
card_type varchar(10) not null,
|
||||||
@ -188,15 +202,14 @@ create table if not exists payment_card_detail
|
|||||||
card_number varchar(20) not null,
|
card_number varchar(20) not null,
|
||||||
approval_number varchar(8) not null, -- 실제로는 unique 이지만 테스트 결제 위젯에서는 항상 000000으로 동일한 값이 나옴.
|
approval_number varchar(8) not null, -- 실제로는 unique 이지만 테스트 결제 위젯에서는 항상 000000으로 동일한 값이 나옴.
|
||||||
installment_plan_months tinyint not null,
|
installment_plan_months tinyint not null,
|
||||||
is_interest_free boolean not null,
|
is_interest_free tinyint(1) not null,
|
||||||
easypay_provider_code varchar(20),
|
easypay_provider_code varchar(20),
|
||||||
easypay_discount_amount integer,
|
easypay_discount_amount integer,
|
||||||
|
|
||||||
constraint fk_payment_card_detail__id foreign key (id) references payment_detail (id)
|
constraint fk_payment_card_detail__id foreign key (id) references payment_detail (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists payment_easypay_prepaid_detail
|
create table if not exists payment_easypay_prepaid_detail(
|
||||||
(
|
|
||||||
id bigint primary key,
|
id bigint primary key,
|
||||||
easypay_provider_code varchar(20) not null,
|
easypay_provider_code varchar(20) not null,
|
||||||
amount integer not null,
|
amount integer not null,
|
||||||
@ -205,8 +218,7 @@ create table if not exists payment_easypay_prepaid_detail
|
|||||||
constraint fk_payment_easypay_prepaid_detail__id foreign key (id) references payment_detail (id)
|
constraint fk_payment_easypay_prepaid_detail__id foreign key (id) references payment_detail (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table if not exists canceled_payment
|
create table if not exists canceled_payment(
|
||||||
(
|
|
||||||
id bigint primary key,
|
id bigint primary key,
|
||||||
payment_id bigint not null,
|
payment_id bigint not null,
|
||||||
requested_at datetime(6) not null,
|
requested_at datetime(6) not null,
|
||||||
@ -219,6 +231,5 @@ create table if not exists canceled_payment
|
|||||||
easypay_discount_amount integer not null,
|
easypay_discount_amount integer not null,
|
||||||
|
|
||||||
constraint uk_canceled_payment__paymentId unique (payment_id),
|
constraint uk_canceled_payment__paymentId unique (payment_id),
|
||||||
constraint fk_canceled_payment__paymentId foreign key (payment_id) references payment(id),
|
constraint fk_canceled_payment__paymentId foreign key (payment_id) references payment(id)
|
||||||
constraint fk_canceled_payment__canceledBy foreign key (canceled_by) references members(member_id)
|
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user