X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=sql%2Fsql.d%2F060-tournament.sql;h=90b54a21f5a404131fa68efde509df5039c1b2c7;hb=484a365c1e66ba4b878117275423a1594c209960;hp=d3f249af020aca24289ad1230333aeb04e56aa4b;hpb=ebf674a03fdbc3e281dd99e6e271ebec24e2448e;p=brisk.git diff --git a/sql/sql.d/060-tournament.sql b/sql/sql.d/060-tournament.sql index d3f249a..90b54a2 100644 --- a/sql/sql.d/060-tournament.sql +++ b/sql/sql.d/060-tournament.sql @@ -1,16 +1,20 @@ -DROP TABLE #PFX#bin5_tournaments; +DROP TABLE IF EXISTS #PFX#bin5_tournaments; CREATE TABLE #PFX#bin5_tournaments ( code SERIAL PRIMARY KEY, + active integer, name text ); -- add tournaments and field in the bin5_matches table -INSERT INTO #PFX#bin5_tournaments (code, name) VALUES (1, 'normal match'); -ALTER SEQUENCE #PFX#bin5_tournaments_code_seq RESTART WITH 2; +INSERT INTO #PFX#bin5_tournaments (code, active, name) VALUES (1, 1, 'normal match'); +INSERT INTO #PFX#bin5_tournaments (code, active, name) VALUES (2, 1, 'special match'); +ALTER SEQUENCE #PFX#bin5_tournaments_code_seq RESTART WITH 3; -ALTER TABLE #PFX#bin5_matches DROP COLUMN tourn; -ALTER TABLE #PFX#bin5_matches ADD COLUMN tourn integer DEFAULT 1; +ALTER TABLE #PFX#bin5_matches DROP COLUMN tcode; +ALTER TABLE #PFX#bin5_matches ADD COLUMN tcode integer DEFAULT 1; -ALTER TABLE #PFX#bin5_matches DROP CONSTRAINT #PFX#bin5_matches_tourn_fkey; -ALTER TABLE #PFX#bin5_matches ADD FOREIGN KEY (tourn) REFERENCES #PFX#bin5_tournaments(code) ON UPDATE cascade ON DELETE cascade; +ALTER TABLE #PFX#bin5_matches DROP CONSTRAINT #PFX#bin5_matches_tcode_fkey; +ALTER TABLE #PFX#bin5_matches ADD FOREIGN KEY (tcode) REFERENCES #PFX#bin5_tournaments(code) ON UPDATE cascade ON DELETE cascade; +ALTER TABLE #PFX#bin5_games DROP COLUMN act; +ALTER TABLE #PFX#bin5_games ADD COLUMN act integer DEFAULT -1; -- end reason of the game