Clarify reserved negative-risk outcomes without reissuing positions
This commit is contained in:
@@ -200,3 +200,21 @@ CREATE TABLE IF NOT EXISTS neg_risk_members (
|
||||
market TEXT PRIMARY KEY REFERENCES markets, group_id TEXT NOT NULL REFERENCES neg_risk_groups,
|
||||
ordinal INTEGER NOT NULL, UNIQUE(group_id,ordinal)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS augmented_outcomes (
|
||||
market TEXT PRIMARY KEY REFERENCES neg_risk_members(market),
|
||||
group_id TEXT NOT NULL REFERENCES neg_risk_groups(id),
|
||||
role TEXT NOT NULL CHECK(role IN ('named','placeholder','other')),
|
||||
name TEXT, question TEXT, clarification TEXT, named_at INTEGER,
|
||||
CHECK ((role='placeholder')=(name IS NULL)),
|
||||
UNIQUE(group_id,name)
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS augmented_other ON augmented_outcomes(group_id) WHERE role='other';
|
||||
CREATE TABLE IF NOT EXISTS augmented_results (
|
||||
group_id TEXT PRIMARY KEY REFERENCES neg_risk_groups(id),
|
||||
observed_name TEXT NOT NULL, winner TEXT NOT NULL REFERENCES augmented_outcomes(market),
|
||||
evidence TEXT NOT NULL
|
||||
);
|
||||
CREATE TRIGGER IF NOT EXISTS reject_placeholder_orders BEFORE INSERT ON orders
|
||||
WHEN EXISTS(SELECT 1 FROM augmented_outcomes WHERE market=NEW.market AND role='placeholder')
|
||||
BEGIN SELECT RAISE(ABORT,'outcome has not been named'); END;
|
||||
|
||||
Reference in New Issue
Block a user