Add contest table and routes
This commit is contained in:
@@ -9,6 +9,7 @@ DROP TABLE IF EXISTS Review;
|
||||
DROP TABLE IF EXISTS Song;
|
||||
DROP TABLE IF EXISTS "User"; -- Quoted because USER is a reserved keyword
|
||||
DROP TABLE IF EXISTS Team;
|
||||
DROP TABLE IF EXISTS Contest;
|
||||
DROP TABLE IF EXISTS CountryCodes;
|
||||
DROP VIEW IF EXISTS ReviewSummary;
|
||||
DROP VIEW IF EXISTS ReviewSummaryByTeam;
|
||||
@@ -17,6 +18,7 @@ DROP SEQUENCE IF EXISTS group_id_seq;
|
||||
DROP SEQUENCE IF EXISTS user_id_seq;
|
||||
DROP SEQUENCE IF EXISTS song_id_seq;
|
||||
DROP SEQUENCE IF EXISTS review_id_seq;
|
||||
DROP SEQUENCE IF EXISTS contest_id_seq;
|
||||
|
||||
-- =============================================================================
|
||||
-- Sequences for Primary Keys
|
||||
@@ -25,6 +27,23 @@ CREATE SEQUENCE group_id_seq START 1;
|
||||
CREATE SEQUENCE user_id_seq START 1;
|
||||
CREATE SEQUENCE song_id_seq START 1;
|
||||
CREATE SEQUENCE review_id_seq START 1;
|
||||
CREATE SEQUENCE contest_id_seq START 1;
|
||||
|
||||
-- =============================================================================
|
||||
-- Table: Contest
|
||||
-- Stores information about Eurovision contests by year.
|
||||
-- =============================================================================
|
||||
CREATE TABLE Contest (
|
||||
id INTEGER PRIMARY KEY DEFAULT nextval('contest_id_seq'), -- Use sequence for auto-increment
|
||||
year INTEGER DEFAULT EXTRACT(YEAR FROM CURRENT_DATE) NOT NULL, -- The year of the Eurovision contest
|
||||
is_active BOOLEAN DEFAULT TRUE NOT NULL, -- Flag indicating if this is the active contest
|
||||
finals_date DATE NOT NULL, -- Date of the finals
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- Timestamp when the contest was created
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP -- Timestamp when the contest was last updated
|
||||
);
|
||||
|
||||
-- Add index for faster lookups by year
|
||||
CREATE INDEX idx_contest_year ON Contest (year);
|
||||
|
||||
-- =============================================================================
|
||||
-- Table: Group
|
||||
@@ -183,6 +202,9 @@ INSERT INTO CountryCodes (code, name_en, name_fi, name_sv) VALUES ('CHE', 'Switz
|
||||
INSERT INTO CountryCodes (code, name_en, name_fi, name_sv) VALUES ('UKR', 'Ukraine', 'Ukraina', 'Ukraina');
|
||||
INSERT INTO CountryCodes (code, name_en, name_fi, name_sv) VALUES ('GBR', 'United Kingdom', 'Englanti', 'Storbritannien');
|
||||
|
||||
|
||||
-- TODO: Clean this next year. Its now here just to get the show running
|
||||
INSERT INTO Contest (year, finals_date) VALUES (2025, '2025-05-16');
|
||||
-- =============================================================================
|
||||
-- Views (Optional - Not Created Here Based on Documentation Decision)
|
||||
-- =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user