Moved around more code. Implemented more sqlc. Added support to generate swagger.
Added support for profiling. Removed the pkg module altogether. Everything except old sync is now using code generated by sqlc.
This commit is contained in:
4
internal/db/migrations/000001_create_tables.down.sql
Normal file
4
internal/db/migrations/000001_create_tables.down.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
DROP TABLE game;
|
||||
DROP TABLE song;
|
||||
DROP TABLE song_list;
|
||||
DROP TABLE vgmq;
|
||||
43
internal/db/migrations/000001_create_tables.up.sql
Normal file
43
internal/db/migrations/000001_create_tables.up.sql
Normal file
@@ -0,0 +1,43 @@
|
||||
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);
|
||||
@@ -0,0 +1,3 @@
|
||||
Alter table game
|
||||
alter column number_of_songs set null,
|
||||
alter column hash set null;
|
||||
19
internal/db/migrations/000002_adjust_fields_for_sqlc.up.sql
Normal file
19
internal/db/migrations/000002_adjust_fields_for_sqlc.up.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
BEGIN;
|
||||
UPDATE game
|
||||
SET number_of_songs = 0
|
||||
WHERE number_of_songs IS NULL;
|
||||
UPDATE game
|
||||
SET hash = ''
|
||||
WHERE hash IS NULL;
|
||||
UPDATE song
|
||||
SET hash = ''
|
||||
WHERE hash IS NULL;
|
||||
COMMIT;
|
||||
BEGIN;
|
||||
Alter table game
|
||||
alter column number_of_songs set not null,
|
||||
alter column number_of_songs set default 0,
|
||||
ALTER COLUMN hash SET NOT NULL;
|
||||
ALTER TABLE song
|
||||
ALTER COLUMN hash SET NOT NULL;
|
||||
COMMIT;
|
||||
5
internal/db/migrations/000003_fix_times_played.down.sql
Normal file
5
internal/db/migrations/000003_fix_times_played.down.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
Alter table game
|
||||
alter column times_played set null;
|
||||
|
||||
Alter table song
|
||||
alter column times_played set null;
|
||||
5
internal/db/migrations/000003_fix_times_played.up.sql
Normal file
5
internal/db/migrations/000003_fix_times_played.up.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
Alter table game
|
||||
alter column times_played set not null;
|
||||
|
||||
Alter table song
|
||||
alter column times_played set not null;
|
||||
Reference in New Issue
Block a user