maatma: redesign pong storage, to reduce CPU and IO consumption

This commit is contained in:
nemunaire 2021-03-18 21:21:06 +01:00
commit 656e16083d
2 changed files with 10 additions and 4 deletions

View file

@ -114,8 +114,10 @@ CREATE TABLE IF NOT EXISTS student_challenge_errors(
if _, err := db.Exec(`
CREATE TABLE IF NOT EXISTS student_pong(
id_student INTEGER NOT NULL,
time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
last TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
count INTEGER UNSIGNED DEFAULT 1,
state BOOLEAN NOT NULL DEFAULT 0,
CONSTRAINT one_pong UNIQUE (id_student,state),
FOREIGN KEY(id_student) REFERENCES students(id_student)
) DEFAULT CHARACTER SET = utf8 COLLATE = utf8_bin;
`); err != nil {