-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: exam description varchar to text
- Loading branch information
Showing
4 changed files
with
71 additions
and
69 deletions.
There are no files selected for viewing
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,92 +1,90 @@ | ||
-- PostgreSQL | ||
|
||
CREATE TABLE IF NOT EXISTS MEMBER | ||
CREATE TABLE IF NOT EXISTS member | ||
( | ||
ID BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
NAME VARCHAR(255) NOT NULL, | ||
EMAIL VARCHAR(255), | ||
AVATAR_URL VARCHAR(255) NOT NULL, | ||
SOCIAL_ID VARCHAR(255) NOT NULL, | ||
PROVIDER VARCHAR(20) NOT NULL, | ||
CREATED_AT TIMESTAMP(6) NOT NULL, | ||
UPDATED_AT TIMESTAMP(6) NOT NULL, | ||
PRIMARY KEY (ID) | ||
id BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
name VARCHAR(255) NOT NULL, | ||
email VARCHAR(255), | ||
avatar_url VARCHAR(255) NOT NULL, | ||
social_id VARCHAR(255) NOT NULL, | ||
provider VARCHAR(20) NOT NULL, | ||
created_at TIMESTAMP(6) NOT NULL, | ||
updated_at TIMESTAMP(6) NOT NULL, | ||
PRIMARY KEY (id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS EXAM | ||
CREATE TABLE IF NOT EXISTS exam | ||
( | ||
ID BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
MEMBER_ID BIGINT NOT NULL, | ||
TITLE VARCHAR(255) NOT NULL, | ||
DESCRIPTION VARCHAR(255) NOT NULL, | ||
STATUS VARCHAR(20) NOT NULL, | ||
CREATED_AT TIMESTAMP(6) NOT NULL, | ||
START_AT TIMESTAMP(6), | ||
END_AT TIMESTAMP(6), | ||
UPDATED_AT TIMESTAMP(6) NOT NULL, | ||
PRIMARY KEY (ID) | ||
id BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
member_id BIGINT NOT NULL, | ||
title VARCHAR(255) NOT NULL, | ||
description VARCHAR(255) NOT NULL, | ||
status VARCHAR(20) NOT NULL, | ||
created_at TIMESTAMP(6) NOT NULL, | ||
start_at TIMESTAMP(6), | ||
end_at TIMESTAMP(6), | ||
updated_at TIMESTAMP(6) NOT NULL, | ||
PRIMARY KEY (id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS ANSWER | ||
CREATE TABLE IF NOT EXISTS answer | ||
( | ||
ID BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
QUESTION_ID BIGINT NOT NULL, | ||
SUBMISSION_ID BIGINT, | ||
TEXT VARCHAR(255), | ||
PRIMARY KEY (ID) | ||
id BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
question_id BIGINT NOT NULL, | ||
submission_id BIGINT, | ||
text VARCHAR(255), | ||
PRIMARY KEY (id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS ANSWER_CHOICE | ||
CREATE TABLE IF NOT EXISTS answer_choice | ||
( | ||
ANSWER_ID BIGINT NOT NULL, | ||
QUESTION_OPTION_ID BIGINT NOT NULL | ||
answer_id BIGINT NOT NULL, | ||
question_option_id BIGINT NOT NULL | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS QUESTION | ||
CREATE TABLE IF NOT EXISTS question | ||
( | ||
ID BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
EXAM_ID BIGINT, | ||
TEXT VARCHAR(255) NOT NULL, | ||
CORRECT_ANSWER VARCHAR(255), | ||
TYPE VARCHAR(50) NOT NULL, | ||
PRIMARY KEY (ID) | ||
id BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
exam_id BIGINT, | ||
text VARCHAR(255) NOT NULL, | ||
correct_answer VARCHAR(255), | ||
type VARCHAR(50) NOT NULL, | ||
PRIMARY KEY (id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS QUESTION_OPTION | ||
CREATE TABLE IF NOT EXISTS question_option | ||
( | ||
ID BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
QUESTION_ID BIGINT, | ||
TEXT VARCHAR(255) NOT NULL, | ||
IS_CORRECT BOOLEAN NOT NULL, | ||
PRIMARY KEY (ID) | ||
id BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
question_id BIGINT, | ||
text VARCHAR(255) NOT NULL, | ||
is_correct BOOLEAN NOT NULL, | ||
PRIMARY KEY (id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS SUBMISSION | ||
CREATE TABLE IF NOT EXISTS submission | ||
( | ||
ID BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
EXAM_ID BIGINT NOT NULL, | ||
MEMBER_ID BIGINT NOT NULL, | ||
CREATED_AT TIMESTAMP(6) NOT NULL, | ||
UPDATED_AT TIMESTAMP(6) NOT NULL, | ||
PRIMARY KEY (ID) | ||
id BIGINT GENERATED BY DEFAULT AS IDENTITY, | ||
exam_id BIGINT NOT NULL, | ||
member_id BIGINT NOT NULL, | ||
created_at TIMESTAMP(6) NOT NULL, | ||
updated_at TIMESTAMP(6) NOT NULL, | ||
PRIMARY KEY (id) | ||
); | ||
|
||
ALTER TABLE IF EXISTS ANSWER | ||
ADD CONSTRAINT FK_SUBMISSION | ||
FOREIGN KEY (SUBMISSION_ID) | ||
REFERENCES SUBMISSION (ID); | ||
ALTER TABLE IF EXISTS answer | ||
ADD CONSTRAINT fk_submission | ||
FOREIGN KEY (submission_id) | ||
REFERENCES submission (id); | ||
|
||
ALTER TABLE IF EXISTS ANSWER_CHOICE | ||
ADD CONSTRAINT FK_ANSWER | ||
FOREIGN KEY (ANSWER_ID) | ||
REFERENCES ANSWER (ID); | ||
ALTER TABLE IF EXISTS answer_choice | ||
ADD CONSTRAINT fk_answer | ||
FOREIGN KEY (answer_id) | ||
REFERENCES answer (id); | ||
|
||
ALTER TABLE IF EXISTS QUESTION | ||
ADD CONSTRAINT FK_EXAM | ||
FOREIGN KEY (EXAM_ID) | ||
REFERENCES EXAM (ID); | ||
ALTER TABLE IF EXISTS question | ||
ADD CONSTRAINT fk_exam | ||
FOREIGN KEY (exam_id) | ||
REFERENCES exam (id); | ||
|
||
ALTER TABLE IF EXISTS QUESTION_OPTION | ||
ADD CONSTRAINT FK_QUESTION | ||
FOREIGN KEY (QUESTION_ID) | ||
REFERENCES QUESTION (ID); | ||
ALTER TABLE IF EXISTS question_option | ||
ADD CONSTRAINT fk_question | ||
FOREIGN KEY (question_id) | ||
REFERENCES question (id); |
2 changes: 2 additions & 0 deletions
2
server/src/main/resources/db/migration/V2__update_description_length.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,2 @@ | ||
ALTER TABLE exam | ||
ALTER COLUMN description TYPE TEXT; |
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
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