Skip to content

Commit

Permalink
[ADD] 외래키 제약 추가 #103
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin409 committed Feb 8, 2024
1 parent 7e8fed5 commit bef8fef
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/main/resources/db/migration/V6__update-timeline-lineup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,39 @@ CREATE TABLE score_records
id BIGINT AUTO_INCREMENT NOT NULL,
record_id BIGINT NOT NULL,
lineup_player_id BIGINT NOT NULL,
score INT NOT NULL
score INT NOT NULL,
PRIMARY KEY (id)
);

ALTER TABLE score_records
ADD CONSTRAINT FK_RECORDS_IN_SCORE_RECORDS FOREIGN KEY (record_id) REFERENCES records (id);

ALTER TABLE score_records
ADD CONSTRAINT FK_LINEUP_PLAYER_ID FOREIGN KEY (lineup_player_id) REFERENCES lineup_players (id);

CREATE TABLE replacement_records
(
id BIGINT AUTO_INCREMENT NOT NULL,
record_id BIGINT NOT NULL,
origin_lineup_player_id BIGINT NOT NULL,
replaced_lineup_player_id BIGINT NOT NULL
replaced_lineup_player_id BIGINT NOT NULL,
PRIMARY KEY (id)
);

ALTER TABLE replacement_records
ADD CONSTRAINT FK_RECORDS_IN_REPLACEMENT_RECORDS FOREIGN KEY (record_id) REFERENCES records (id);

ALTER TABLE replacement_records
ADD CONSTRAINT FK_ORIGIN_LINEUP_PLAYER FOREIGN KEY (origin_lineup_player_id) REFERENCES lineup_players (id);

ALTER TABLE replacement_records
ADD CONSTRAINT FK_REPLACED_LINEUP_PLAYER FOREIGN KEY (replaced_lineup_player_id) REFERENCES lineup_players (id);

ALTER TABLE league_team_players
ADD COLUMN number INT;
ADD COLUMN number INT NULL;

ALTER TABLE lineup_players
ADD COLUMN number INT;

ALTER TABLE lineup_players
ADD COLUMN is_captain BOOLEAN;
ADD COLUMN is_captain BOOLEAN;

0 comments on commit bef8fef

Please sign in to comment.