File size: 1,264 Bytes
7f68ba0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- Migration 012: extend onevone_matches.challenge_type CHECK to include
-- `vulnerability-hunter` (added to the verifier dispatch in
-- app/api/onevone.py after the table was created).
--
-- Idempotent: re-runnable; drops any existing constraint whose name starts
-- with `onevone_matches_challenge_type_check` and recreates it with the
-- extended whitelist.

BEGIN;

-- Drop the old constraint (if it exists under any of the names we've used).
ALTER TABLE public.onevone_matches
  DROP CONSTRAINT IF EXISTS onevone_matches_challenge_type_check;

-- Add the new one with `vulnerability-hunter` allowed.
ALTER TABLE public.onevone_matches
  ADD CONSTRAINT onevone_matches_challenge_type_check
  CHECK (challenge_type IN (
    'crypto',
    'web',
    'code-fixing',
    'log-analysis',
    'vulnerability-hunter'
  ));

COMMIT;

-- ---------------------------------------------------------------------------
-- Verification:
--   SELECT conname, pg_get_constraintdef(oid)
--     FROM pg_constraint
--    WHERE conrelid = 'public.onevone_matches'::regclass
--      AND conname = 'onevone_matches_challenge_type_check';
-- Expected: a single row whose definition includes all 5 values.
-- ---------------------------------------------------------------------------