torneos/database/migrations/20260519_ltv26_template_fie...

15 lines
780 B
SQL

CREATE TABLE IF NOT EXISTS match_sheet_details (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
match_id BIGINT UNSIGNED NOT NULL,
team_id BIGINT UNSIGNED,
captain_player_id BIGINT UNSIGNED,
coach_name VARCHAR(160),
observations TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT fk_sheet_details_match FOREIGN KEY (match_id) REFERENCES matches(id) ON DELETE CASCADE,
CONSTRAINT fk_sheet_details_team FOREIGN KEY (team_id) REFERENCES teams(id) ON DELETE CASCADE,
CONSTRAINT fk_sheet_details_captain FOREIGN KEY (captain_player_id) REFERENCES players(id) ON DELETE SET NULL,
UNIQUE KEY uq_sheet_match_team (match_id, team_id)
) ENGINE=InnoDB;