cyberhybridhub/server/migrations/012_prospective_questions_slot_pair_key.sql

15 lines
697 B
SQL

-- One question per symbol per canonical (older, newer) session-half slot pair.
ALTER TABLE market_history_prospective_questions
DROP CONSTRAINT IF EXISTS market_history_prospective_questions_compare_until_symbol_key;
ALTER TABLE market_history_prospective_questions
DROP CONSTRAINT IF EXISTS market_history_prospective_questions_slot_pair_symbol_key;
ALTER TABLE market_history_prospective_questions
ADD CONSTRAINT market_history_prospective_questions_slot_pair_symbol_key
UNIQUE (symbol, older_slot_start, newer_slot_start);
CREATE INDEX IF NOT EXISTS market_history_prospective_questions_slot_pair_idx
ON market_history_prospective_questions (older_slot_start, newer_slot_start);