-- Add new columns to assertions table for dynamic UI handling
DO $$
BEGIN
    IF NOT EXISTS (
        SELECT 1
        FROM information_schema.columns
        WHERE table_name='assertions' AND column_name='value_type'
    ) THEN
        ALTER TABLE assertions ADD COLUMN value_type TEXT;
    END IF;
END$$;

DO $$
BEGIN
    IF NOT EXISTS (
        SELECT 1
        FROM information_schema.columns
        WHERE table_name='assertions' AND column_name='mandatory'
    ) THEN
        ALTER TABLE assertions ADD COLUMN mandatory INTEGER DEFAULT 0;
    END IF;
END$$;

DO $$
BEGIN
    IF NOT EXISTS (
        SELECT 1
        FROM information_schema.columns
        WHERE table_name='assertions' AND column_name='additional_fields'
    ) THEN
        ALTER TABLE assertions ADD COLUMN additional_fields JSONB;
    END IF;
END$$;