database schema: add (in)feasibility tables, add detrimental_characters
This commit is contained in:
parent
b893a65a64
commit
11279a1c68
2 changed files with 34 additions and 17 deletions
|
@ -22,9 +22,26 @@ CREATE TABLE games (
|
|||
one_extra_card BOOLEAN,
|
||||
one_less_card BOOLEAN,
|
||||
all_or_nothing BOOLEAN,
|
||||
detrimental_characters BOOLEAN,
|
||||
num_turns SMALLINT,
|
||||
actions TEXT
|
||||
);
|
||||
CREATE INDEX games_seed_score_idx ON games (seed, score);
|
||||
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 (
|
||||
seed TEXT NOT NULL REFERENCES seeds ON DELETE CASCADE,
|
||||
score_upper_bound SMALLINT NOT NULL,
|
||||
reason SMALLINT NOT NULL
|
||||
);
|
||||
|
||||
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,
|
||||
CHECK (num_nonnulls(game_id, actions) = 1)
|
||||
);
|
|
@ -155,18 +155,18 @@ def detailed_export_game(
|
|||
database.cur.execute(
|
||||
"INSERT INTO games ("
|
||||
"id, num_players, score, seed, variant_id, deck_plays, one_extra_card, one_less_card,"
|
||||
"all_or_nothing, actions"
|
||||
"all_or_nothing, detrimental_characters, actions"
|
||||
")"
|
||||
"VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
||||
"VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
||||
"ON CONFLICT (id) DO UPDATE SET ("
|
||||
"deck_plays, one_extra_card, one_less_card, all_or_nothing, actions"
|
||||
"deck_plays, one_extra_card, one_less_card, all_or_nothing, actions, detrimental_characters"
|
||||
") = ("
|
||||
"EXCLUDED.deck_plays, EXCLUDED.one_extra_card, EXCLUDED.one_less_card, EXCLUDED.all_or_nothing,"
|
||||
"EXCLUDED.actions"
|
||||
"EXCLUDED.actions, EXCLUDED.detrimental_characters"
|
||||
")",
|
||||
(
|
||||
game_id, num_players, score, seed, var_id, deck_plays, one_extra_card, one_less_card,
|
||||
all_or_nothing, compressed_actions
|
||||
all_or_nothing, detrimental_characters, compressed_actions
|
||||
)
|
||||
)
|
||||
logger.debug("Imported game {}".format(game_id))
|
||||
|
|
Loading…
Reference in a new issue