2024-08-03 17:32:21 -05:00
|
|
|
create table if not exists plays (
|
2024-07-24 21:17:36 -05:00
|
|
|
"json" text unique on conflict ignore,
|
|
|
|
|
"posted" integer check ("posted" in (0, 1))
|
|
|
|
|
);
|
|
|
|
|
|
2024-08-03 17:32:21 -05:00
|
|
|
create index if not exists nonposted_plays
|
|
|
|
|
on plays(posted)
|
|
|
|
|
where posted = 0;
|
|
|
|
|
|
|
|
|
|
create table if not exists highlights (
|
|
|
|
|
"json" text unique on conflict ignore,
|
|
|
|
|
"posted" integer check ("posted" in (0, 1))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
create index if not exists nonposted_highlights
|
|
|
|
|
on highlights(posted)
|
2024-07-24 21:17:36 -05:00
|
|
|
where posted = 0;
|
2024-08-03 15:39:24 -05:00
|
|
|
|
|
|
|
|
create table if not exists games (
|
2024-08-08 22:17:11 -05:00
|
|
|
"json" text unique on conflict ignore,
|
2024-08-10 15:11:46 -05:00
|
|
|
"posted" integer check ("posted" in (0, 1))
|
2024-08-03 15:39:24 -05:00
|
|
|
);
|
2024-08-04 00:13:13 -05:00
|
|
|
|
2024-08-08 22:17:11 -05:00
|
|
|
create index if not exists nonposted_games
|
|
|
|
|
on games(posted)
|
|
|
|
|
where posted = 0;
|
2024-08-11 01:17:13 -05:00
|
|
|
|
|
|
|
|
create trigger if not exists delete_old_states
|
|
|
|
|
before insert on games
|
|
|
|
|
begin
|
|
|
|
|
delete from games
|
|
|
|
|
where json ->> 'gamePk' = new.json ->> 'gamePk' and
|
|
|
|
|
json ->> 'status' ->> 'detailedState' != new.json ->> 'status' ->> 'detailedState';
|
|
|
|
|
end;
|