START TRANSACTION;

CREATE TYPE campaign_type AS ENUM ('DRAFT', 'AGGREGATED');

ALTER TABLE campaign
    ADD COLUMN IF NOT EXISTS campaign_type campaign_type NOT NULL DEFAULT 'AGGREGATED';

ALTER TABLE quota_request
    ADD COLUMN IF NOT EXISTS campaign_type campaign_type NOT NULL DEFAULT 'AGGREGATED';

CREATE INDEX IF NOT EXISTS quota_request_campaign_type_id ON quota_request (campaign_type, id);

COMMIT;
