CREATE TABLE game (
	id serial4 NOT NULL,
	game_name varchar NOT NULL,
	added timestamp NOT NULL,
	deleted timestamp NULL,
	last_changed timestamp NULL,
	"path" varchar NOT NULL,
	times_played int4 DEFAULT 0 NULL,
	last_played timestamp NULL,
	number_of_songs int4 NULL,
	hash varchar NULL,
	CONSTRAINT game_pkey PRIMARY KEY (id)
);

CREATE TABLE song (
	game_id int4 NOT NULL,
	song_name varchar NOT NULL,
	"path" varchar NOT NULL,
	times_played int4 DEFAULT 0 NULL,
	hash varchar NULL,
	file_name varchar NULL,
	CONSTRAINT song_pkey PRIMARY KEY (game_id, path)
);

CREATE TABLE vgmq (
	song_no int4 NOT NULL,
	"path" varchar(50) NULL,
	clue varchar(200) NULL,
	answered bool DEFAULT false NOT NULL,
	answer varchar(50) NULL,
	CONSTRAINT vgmq_pk PRIMARY KEY (song_no)
);
CREATE UNIQUE INDEX vgmq_song_no_uindex ON vgmq USING btree (song_no);

CREATE TABLE song_list (
	match_date date NOT NULL,
	match_id int4 NOT NULL,
	song_no int4 NOT NULL,
	game_name varchar(50) NULL,
	song_name varchar(50) NULL,
	CONSTRAINT song_list_pkey PRIMARY KEY (match_date, match_id, song_no)
);
CREATE INDEX song_list_game_name_idx ON song_list USING btree (game_name);
