diff --git a/src/main/resources/schema/schema-h2.sql b/src/main/resources/schema/schema-h2.sql index 64c1439d..978bbae1 100644 --- a/src/main/resources/schema/schema-h2.sql +++ b/src/main/resources/schema/schema-h2.sql @@ -18,6 +18,60 @@ create table if not exists members ( last_modified_at timestamp ); +create table if not exists users( + id bigint primary key, + name varchar(50) not null, + email varchar(255) not null, + password varchar(255) not null, + phone varchar(20) not null, + region_code varchar(10) not null, + status varchar(20) not null, + created_at timestamp not null, + created_by bigint not null, + updated_at timestamp not null, + updated_by bigint not null, + + constraint uk__users_email unique (email), + constraint uk__users_phone unique (phone), + constraint fk__users_region_code foreign key (region_code) references region (code) +); + +create table if not exists user_status_history( + id bigint primary key, + user_id bigint not null, + status varchar(20) not null, + reason varchar(255) not null, + created_at timestamp not null, + created_by bigint not null, + updated_at timestamp not null, + updated_by bigint not null, + + constraint fk__user_status_history_user_id foreign key (user_id) references users (id) +); + +create table if not exists admin( + id bigint primary key, + account varchar(20) not null, + password varchar(255) not null, + name varchar(20) not null, + phone varchar(20) not null, + permission_level varchar(20) not null, + created_at timestamp not null, + created_by bigint not null, + updated_at timestamp not null, + updated_by bigint not null +); + +create table if not exists login_history( + id bigint primary key, + principal_id bigint not null, + principal_type varchar(20) not null, + success boolean not null, + ip_address varchar(45) not null, + user_agent varchar(255) not null, + created_at timestamp not null +); + create table if not exists theme ( id bigint primary key , name varchar(30) not null, diff --git a/src/main/resources/schema/schema-mysql.sql b/src/main/resources/schema/schema-mysql.sql index cae84864..54d4d19d 100644 --- a/src/main/resources/schema/schema-mysql.sql +++ b/src/main/resources/schema/schema-mysql.sql @@ -19,6 +19,60 @@ create table if not exists members last_modified_at datetime(6) null ); +create table if not exists users( + id bigint primary key, + name varchar(50) not null, + email varchar(255) not null, + password varchar(255) not null, + phone varchar(20) not null, + region_code varchar(10) not null, + status varchar(20) not 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__users_email unique (email), + constraint uk__users_phone unique (phone), + constraint fk__users_region_code foreign key (region_code) references region (code) +); + +create table if not exists user_status_history( + id bigint primary key, + user_id bigint not null, + status varchar(20) not null, + reason varchar(255) not null, + created_at datetime(6) not null, + created_by bigint not null, + updated_at datetime(6) not null, + updated_by bigint not null, + + constraint fk__user_status_history_user_id foreign key (user_id) references users (id) +); + +create table if not exists admin( + id bigint primary key, + account varchar(20) not null, + password varchar(255) not null, + name varchar(20) not null, + phone varchar(20) not null, + permission_level varchar(20) not null, + created_at datetime(6) not null, + created_by bigint not null, + updated_at datetime(6) not null, + updated_by bigint not null +); + +create table if not exists login_history( + id bigint primary key, + principal_id bigint not null, + principal_type varchar(20) not null, + success boolean not null, + ip_address varchar(45) not null, + user_agent varchar(255) not null, + created_at datetime(6) not null +); + create table if not exists theme ( id bigint primary key , name varchar(30) not null,