-DROP TABLE #PFX#bin5_tournaments;
+DROP TABLE IF EXISTS #PFX#bin5_tournaments;
CREATE TABLE #PFX#bin5_tournaments (
code SERIAL PRIMARY KEY,
active integer,
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; -- end reason of the game
+ALTER TABLE #PFX#bin5_games ADD COLUMN act integer DEFAULT -1; -- end reason of the game