mlblive-mastodon-scripts/schema.sql

33 lines
758 B
MySQL
Raw Normal View History

2024-08-03 22:32:21 +00:00
create table if not exists plays (
2024-07-25 02:17:36 +00:00
"json" text unique on conflict ignore,
"posted" integer check ("posted" in (0, 1))
);
2024-08-03 22:32:21 +00: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-25 02:17:36 +00:00
where posted = 0;
2024-08-03 20:39:24 +00:00
create table if not exists games (
gamePk integer,
2024-08-04 19:54:43 +00:00
json text,
posted integer,
2024-08-06 03:44:18 +00:00
unique (gamePk) on conflict ignore
2024-08-03 20:39:24 +00:00
);
create trigger if not exists delete_old_states
before insert on games
begin
delete from games
where gamePk = new.gamePk and
2024-08-04 21:00:48 +00:00
json ->> 'status' ->> 'detailedState' != new.json ->> 'status' ->> 'detailedState';
end;