-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
72 additions
and
37 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/main/resources/db/migration/V3.1__event_point_related_table_fix.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
DROP TABLE IF EXISTS bread_diary_event; | ||
CREATE TABLE bread_diary_event | ||
( | ||
diary_id BIGINT NOT NULL, | ||
created_at datetime NULL, | ||
modified_at datetime NULL, | ||
`description` VARCHAR(2000) NOT NULL DEFAULT '', | ||
state VARCHAR(255) NOT NULL, | ||
CONSTRAINT pk_breaddiaryevent PRIMARY KEY (diary_id) | ||
); | ||
|
||
ALTER TABLE bread_diary_event | ||
ADD CONSTRAINT FK_BREADDIARYEVENT_ON_DIARY FOREIGN KEY (diary_id) REFERENCES bread_diary (id); | ||
|
||
DROP TABLE IF EXISTS user_point; | ||
CREATE TABLE user_point | ||
( | ||
user_id BIGINT NOT NULL, | ||
created_at datetime NULL, | ||
modified_at datetime NULL, | ||
total_point INT NOT NULL, | ||
CONSTRAINT pk_userpoint PRIMARY KEY (user_id) | ||
); | ||
|
||
ALTER TABLE user_point | ||
ADD CONSTRAINT FK_USERPOINT_ON_USER FOREIGN KEY (user_id) REFERENCES user (id); | ||
|
||
DROP TABLE IF EXISTS user_point_history; | ||
CREATE TABLE user_point_history | ||
( | ||
id BIGINT NOT NULL, | ||
created_at datetime NULL, | ||
modified_at datetime NULL, | ||
user_id BIGINT NOT NULL, | ||
point INT NOT NULL, | ||
grand_total_point INT NOT NULL, | ||
type VARCHAR(255) NOT NULL, | ||
`description` VARCHAR(2000) NOT NULL DEFAULT '', | ||
target_id BIGINT NULL, | ||
CONSTRAINT pk_userpointhistory PRIMARY KEY (id) | ||
); | ||
|
||
ALTER TABLE challenge | ||
CHANGE start_datetime start_date_time datetime; | ||
ALTER TABLE challenge | ||
CHANGE end_datetime end_date_time datetime; |
63 changes: 26 additions & 37 deletions
63
src/main/resources/db/migration/V3__event_point_related_table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,33 @@ | ||
DROP TABLE IF EXISTS bread_diary_event; | ||
CREATE TABLE bread_diary_event | ||
( | ||
diary_id BIGINT NOT NULL, | ||
created_at datetime NULL, | ||
modified_at datetime NULL, | ||
`description` VARCHAR(2000) NOT NULL DEFAULT '', | ||
state VARCHAR(255) NOT NULL, | ||
CONSTRAINT pk_breaddiaryevent PRIMARY KEY (diary_id) | ||
CREATE TABLE `bread_diary_event` ( | ||
`diary_id` bigint PRIMARY KEY , | ||
`state` varchar(255) NOT NULL DEFAULT 'PENDING', | ||
`point` int NOT NULL DEFAULT 0, | ||
`description` varchar(4000) NOT NULL DEFAULT '', | ||
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
ALTER TABLE bread_diary_event | ||
ADD CONSTRAINT FK_BREADDIARYEVENT_ON_DIARY FOREIGN KEY (diary_id) REFERENCES bread_diary (id); | ||
CREATE TABLE `point_history` ( | ||
`id` bigint auto_increment PRIMARY KEY, | ||
`user_id` bigint NOT NULL, | ||
`target_id` bigint, | ||
`point` int NOT NULL DEFAULT 0, | ||
`grand_total_point` int NOT NULL DEFAULT 0, | ||
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`type` varchar(255) NOT NULL DEFAULT 'ETC', | ||
`description` varchar(4000) NOT NULL DEFAULT '' | ||
); | ||
|
||
DROP TABLE IF EXISTS user_point; | ||
CREATE TABLE user_point | ||
( | ||
user_id BIGINT NOT NULL, | ||
created_at datetime NULL, | ||
modified_at datetime NULL, | ||
total_point INT NOT NULL, | ||
CONSTRAINT pk_userpoint PRIMARY KEY (user_id) | ||
CREATE TABLE `user_point` ( | ||
`user_id` bigint PRIMARY KEY, | ||
`total_point` int NOT NULL DEFAULT 0, | ||
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
); | ||
|
||
ALTER TABLE user_point | ||
ADD CONSTRAINT FK_USERPOINT_ON_USER FOREIGN KEY (user_id) REFERENCES user (id); | ||
ALTER TABLE `bread_diary_event` ADD FOREIGN KEY (`diary_id`) REFERENCES `bread_diary` (`id`); | ||
|
||
DROP TABLE IF EXISTS user_point_history; | ||
CREATE TABLE user_point_history | ||
( | ||
id BIGINT NOT NULL, | ||
created_at datetime NULL, | ||
modified_at datetime NULL, | ||
user_id BIGINT NOT NULL, | ||
point INT NOT NULL, | ||
grand_total_point INT NOT NULL, | ||
type VARCHAR(255) NOT NULL, | ||
`description` VARCHAR(2000) NOT NULL DEFAULT '', | ||
target_id BIGINT NULL, | ||
CONSTRAINT pk_userpointhistory PRIMARY KEY (id) | ||
); | ||
ALTER TABLE `point_history` ADD FOREIGN KEY (`user_id`) REFERENCES `user` (`id`); | ||
|
||
alter table challenge CHANGE start_datetime start_date_time datetime; | ||
ALTER TABLE challenge CHANGE end_datetime end_date_time datetime; | ||
ALTER TABLE `user_point` ADD FOREIGN KEY (`user_id`) REFERENCES `user` (`id`); |