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
|
@ -13,18 +13,35 @@ CREATE INDEX seeds_variant_idx ON seeds (variant_id);
|
|||
|
||||
DROP TABLE IF EXISTS games CASCADE;
|
||||
CREATE TABLE games (
|
||||
id INT PRIMARY KEY,
|
||||
seed TEXT NOT NULL REFERENCES seeds,
|
||||
num_players SMALLINT NOT NULL,
|
||||
score SMALLINT NOT NULL,
|
||||
variant_id SMALLINT NOT NULL,
|
||||
deck_plays BOOLEAN,
|
||||
one_extra_card BOOLEAN,
|
||||
one_less_card BOOLEAN,
|
||||
all_or_nothing BOOLEAN,
|
||||
num_turns SMALLINT,
|
||||
actions TEXT
|
||||
id INT PRIMARY KEY,
|
||||
seed TEXT NOT NULL REFERENCES seeds,
|
||||
num_players SMALLINT NOT NULL,
|
||||
score SMALLINT NOT NULL,
|
||||
variant_id SMALLINT NOT NULL,
|
||||
deck_plays BOOLEAN,
|
||||
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);
|
||||
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