CREATE TABLE player (
       id serial PRIMARY KEY,
       name varchar(40) UNIQUE NOT NULL
);

CREATE TABLE game (
       id serial PRIMARY KEY,
       name varchar(40) UNIQUE NOT NULL
);

CREATE TABLE win (
       id serial PRIMARY KEY,
       winner integer REFERENCES player(id) NOT NULL,
       loser integer REFERENCES player(id) NOT NULL,
       happened timestamp NOT NULL
);

CREATE TABLE IF NOT EXISTS player (
       id serial PRIMARY KEY,
       name varchar(40) UNIQUE NOT NULL
);

CREATE TABLE IF NOT EXISTS game (
       id serial PRIMARY KEY,
       name varchar(40) UNIQUE NOT NULL
);

CREATE TABLE IF NOT EXISTS win (
       id serial PRIMARY KEY,
       winner integer REFERENCES player(id) NOT NULL,
       loser integer REFERENCES player(id) NOT NULL,
       happened timestamp NOT NULL
);

Make database setup resistant to multiple runs
Make database setup resistant to multiple runs
