pokemon-showdown/databases/schemas/roomlogs.sql
Mia 13a5c1ca52
Roomlogs: Support logging to Cockroach instead of flat files (#10298)
* Roomlogs: Support logging to Cockroach instead of flat files

* Correct roomlog timestamp use

* Remove nonnull cast

* Update server/roomlogs.ts

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>

* remove y/m/d cols

* Fix indices

* consistency

* replace refs

* Fix syntax error

* Separate out dates into an extra table

* Fix other stuff

* Refactor chatlog

* use type param

* prevent crash in child process

* test

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>

* Update server/roomlogs.ts

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>

* RU: Ban Thundurus-T

* Inheritance: Unban Enamorus

* Add ADV RU challenge format

* SSB: Fix Haste Inky's move

* UU: Ban Pelipper

* use miscrosecond precision for timestamps

* cleanup

---------

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
2024-05-15 16:12:07 -05:00

22 lines
595 B
SQL

CREATE TABLE public.roomlogs (
type STRING NOT NULL,
roomid STRING NOT NULL,
userid STRING NULL,
time TIMESTAMP(6) NOT NULL,
log STRING NOT NULL,
INDEX linecount (userid, roomid, time),
INDEX month (roomid, time),
INDEX type (roomid, type, time),
INDEX rename_idx (roomid)
);
-- computed columns have to be added after apparently
ALTER TABLE roomlogs ADD COLUMN content TSVECTOR AS (to_tsvector('english', log)) STORED;
CREATE TABLE public.roomlog_dates (
roomid STRING NOT NULL,
-- YYYY-MM
month STRING NOT NULL,
-- YYYY-MM-DD
date STRING NOT NULL,
PRIMARY KEY (roomid, date)
);