DB: add schemas for lower and upper bounds on score

This commit is contained in:
Maximilian Keßler 2023-07-08 09:47:57 +02:00
parent 98bbe02495
commit 91f3c73eb3
Signed by: max
GPG key ID: BCC5A619923C0BA5
2 changed files with 12 additions and 10 deletions

View file

@ -31,17 +31,19 @@ CREATE INDEX games_var_seed_idx ON games (variant_id, seed);
CREATE INDEX games_player_idx ON games (num_players);
DROP TABLE IF EXISTS infeasibility_certs;
CREATE TABLE infeasibility_certs (
DROP TABLE IF EXISTS score_upper_bounds;
CREATE TABLE score_upper_bounds (
seed TEXT NOT NULL REFERENCES seeds ON DELETE CASCADE,
score_upper_bound SMALLINT NOT NULL,
reason SMALLINT NOT NULL
reason SMALLINT NOT NULL,
UNIQUE (seed, reason)
);
DROP TABLE IF EXISTS feasibility_certs;
CREATE TABLE feasibility_certs (
seed TEXT NOT NULL REFERENCES seeds ON DELETE CASCADE,
game_id INT REFERENCES games ON DELETE CASCADE,
actions TEXT,
DROP TABLE IF EXISTS score_lower_bounds;
CREATE TABLE score_lower_bounds (
seed TEXT NOT NULL REFERENCES seeds ON DELETE CASCADE,
score_lower_bound SMALLINT NOT NULL,
game_id INT REFERENCES games ON DELETE CASCADE,
actions TEXT,
CHECK (num_nonnulls(game_id, actions) = 1)
);

View file

@ -56,8 +56,8 @@ def update_trivially_feasible_games(variant_id):
database.cur.execute("UPDATE seeds SET (feasible, max_score_theoretical) = (%s, %s) WHERE seed = "
"(%s)", (True, variant.max_score, seed))
database.cur.execute(
"INSERT INTO feasibility_certs (seed, game_id) VALUES (%s, %s)",
(seed, game_id)
"INSERT INTO score_lower_bounds (seed, score_lower_bound, game_id) VALUES (%s, %s, %s)",
(seed, variant.max_score, game_id)
)
database.conn.commit()
break