diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-18 22:38:15 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-18 22:38:15 +0900 |
| commit | 9f9efc2bc07810d2e06b37bad94e5922681eadef (patch) | |
| tree | 79bcce2bf065a7ea282aa7855822c3bdee92ee7c /backend/schema.sql | |
| parent | c095200dc79f24c0cd17a2e3ba15c85a2971ea9a (diff) | |
| download | phperkaigi-2026-albatross-9f9efc2bc07810d2e06b37bad94e5922681eadef.tar.gz phperkaigi-2026-albatross-9f9efc2bc07810d2e06b37bad94e5922681eadef.tar.zst phperkaigi-2026-albatross-9f9efc2bc07810d2e06b37bad94e5922681eadef.zip | |
feat: refactor tournament to generic DB-backed N-person bracket
Replace hardcoded 6-person tournament with a generic single-elimination
bracket system backed by new DB tables (tournaments, tournament_entries,
tournament_matches). Includes admin CRUD, standard seeding algorithm,
bye handling, and a CSS Grid bracket renderer on the frontend.
Add comprehensive tests for backend API/admin handlers, seeding logic,
and frontend bracket component.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'backend/schema.sql')
| -rw-r--r-- | backend/schema.sql | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/backend/schema.sql b/backend/schema.sql index 4a4b1ac..1e7f823 100644 --- a/backend/schema.sql +++ b/backend/schema.sql @@ -104,3 +104,33 @@ CREATE TABLE sessions ( ); CREATE INDEX idx_sessions_user_id ON sessions(user_id); CREATE INDEX idx_sessions_expires_at ON sessions(expires_at); + +CREATE TABLE tournaments ( + tournament_id SERIAL PRIMARY KEY, + display_name VARCHAR(255) NOT NULL, + bracket_size INT NOT NULL, + num_rounds INT NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT NOW() +); + +CREATE TABLE tournament_entries ( + tournament_entry_id SERIAL PRIMARY KEY, + tournament_id INT NOT NULL, + user_id INT NOT NULL, + seed INT NOT NULL, + CONSTRAINT fk_tournament_entries_tournament_id FOREIGN KEY(tournament_id) REFERENCES tournaments(tournament_id), + CONSTRAINT fk_tournament_entries_user_id FOREIGN KEY(user_id) REFERENCES users(user_id), + CONSTRAINT uq_tournament_entries_tournament_user UNIQUE(tournament_id, user_id), + CONSTRAINT uq_tournament_entries_tournament_seed UNIQUE(tournament_id, seed) +); + +CREATE TABLE tournament_matches ( + tournament_match_id SERIAL PRIMARY KEY, + tournament_id INT NOT NULL, + round INT NOT NULL, + position INT NOT NULL, + game_id INT, + CONSTRAINT fk_tournament_matches_tournament_id FOREIGN KEY(tournament_id) REFERENCES tournaments(tournament_id), + CONSTRAINT fk_tournament_matches_game_id FOREIGN KEY(game_id) REFERENCES games(game_id), + CONSTRAINT uq_tournament_matches_tournament_round_position UNIQUE(tournament_id, round, position) +); |
