diff --git a/src/main/resources/application-local.yaml b/src/main/resources/application-local.yaml index fb0a7f19..9d0c5b24 100644 --- a/src/main/resources/application-local.yaml +++ b/src/main/resources/application-local.yaml @@ -4,7 +4,7 @@ spring: hibernate: format_sql: true hibernate: - ddl-auto: create-drop + ddl-auto: validate h2: console: enabled: true @@ -15,6 +15,9 @@ spring: driver-class-name: org.h2.Driver username: sa password: + sql: + init: + schema-locations: classpath:schema/schema-h2.sql security: jwt: diff --git a/src/main/resources/schema/schema-h2.sql b/src/main/resources/schema/schema-h2.sql new file mode 100644 index 00000000..ce3b4fdd --- /dev/null +++ b/src/main/resources/schema/schema-h2.sql @@ -0,0 +1,63 @@ +create table if not exists members ( + member_id bigint primary key, + email varchar(255) not null, + name varchar(255) not null, + password varchar(255) not null, + role varchar(20) not null, + created_at timestamp null, + last_modified_at timestamp null +); + +create table if not exists themes ( + theme_id bigint primary key, + description varchar(255) not null, + name varchar(255) not null, + thumbnail varchar(255) not null, + created_at timestamp null, + last_modified_at timestamp null +); + +create table if not exists times ( + time_id bigint primary key, + start_at time not null, + created_at timestamp null, + last_modified_at timestamp null +); + +create table if not exists reservations ( + reservation_id bigint primary key, + date date not null, + member_id bigint not null, + theme_id bigint not null, + time_id bigint not null, + status varchar(30) not null, + created_at timestamp null, + last_modified_at timestamp null, + constraint fk_reservations__themeId foreign key (theme_id) references themes (theme_id), + constraint fk_reservations__memberId foreign key (member_id) references members (member_id), + constraint fk_reservations__timeId foreign key (time_id) references times (time_id) +); + +create table if not exists payments ( + payment_id bigint primary key, + approved_at timestamp not null, + reservation_id bigint not null, + total_amount bigint not null, + order_id varchar(255) not null, + payment_key varchar(255) not null, + created_at timestamp null, + last_modified_at timestamp null, + constraint uk_payments__reservationId unique (reservation_id), + constraint fk_payments__reservationId foreign key (reservation_id) references reservations (reservation_id) +); + +create table if not exists canceled_payments ( + canceled_payment_id bigint primary key, + payment_key varchar(255) not null, + cancel_reason varchar(255) not null, + cancel_amount bigint not null, + approved_at timestamp not null, + canceled_at timestamp not null, + created_at timestamp null, + last_modified_at timestamp null +); diff --git a/src/main/resources/schema/schema-mysql.sql b/src/main/resources/schema/schema-mysql.sql new file mode 100644 index 00000000..b13d5035 --- /dev/null +++ b/src/main/resources/schema/schema-mysql.sql @@ -0,0 +1,69 @@ +create table if not exists members +( + member_id bigint primary key, + email varchar(255) not null, + name varchar(255) not null, + password varchar(255) not null, + role varchar(20) not null, + created_at datetime null, + last_modified_at datetime null +); + +create table if not exists themes +( + theme_id bigint primary key, + description varchar(255) not null, + name varchar(255) not null, + thumbnail varchar(255) not null, + created_at datetime null, + last_modified_at datetime null +); + +create table if not exists times +( + time_id bigint primary key, + start_at time(6) not null, + created_at datetime null, + last_modified_at datetime null +); + +create table if not exists reservations +( + reservation_id bigint primary key, + date date not null, + member_id bigint not null, + theme_id bigint not null, + time_id bigint not null, + status varchar(30) not null, + created_at datetime null, + last_modified_at datetime null, + constraint fk_reservations__themeId foreign key (theme_id) references themes (theme_id), + constraint fk_reservations__memberId foreign key (member_id) references members (member_id), + constraint fk_reservations__timeId foreign key (time_id) references times (time_id) +); + +create table if not exists payments +( + payment_id bigint primary key, + approved_at datetime(6) not null, + reservation_id bigint not null, + total_amount bigint not null, + order_id varchar(255) not null, + payment_key varchar(255) not null, + created_at datetime null, + last_modified_at datetime null, + constraint uk_payments__reservationId unique (reservation_id), + constraint fk_payments__reservationId foreign key (reservation_id) references reservations (reservation_id) +); + +create table if not exists canceled_payments +( + canceled_payment_id bigint primary key, + payment_key varchar(255) not null, + cancel_reason varchar(255) not null, + cancel_amount bigint not null, + approved_at datetime(6) not null, + canceled_at datetime(6) not null, + created_at datetime null, + last_modified_at datetime null +);