/* eslint-disable camelcase */
export const up = (pgm) => {
  pgm.sql(`
    ALTER TABLE pricing_variant_prices
      DROP CONSTRAINT IF EXISTS pricing_variant_prices_vat_rate_check,
      ADD CONSTRAINT pricing_variant_prices_vat_rate_check
        CHECK (vat_rate IN ('general', 'reduced', 'super-reduced'));

    ALTER TABLE pricing_price_history
      DROP CONSTRAINT IF EXISTS pricing_price_history_previous_vat_rate_check,
      ADD CONSTRAINT pricing_price_history_previous_vat_rate_check
        CHECK (previous_vat_rate IS NULL OR previous_vat_rate IN ('general', 'reduced', 'super-reduced'));

    ALTER TABLE pricing_price_history
      DROP CONSTRAINT IF EXISTS pricing_price_history_new_vat_rate_check,
      ADD CONSTRAINT pricing_price_history_new_vat_rate_check
        CHECK (new_vat_rate IN ('general', 'reduced', 'super-reduced'));
  `);
};

export const down = (pgm) => {
  pgm.sql(`
    ALTER TABLE pricing_variant_prices
      DROP CONSTRAINT IF EXISTS pricing_variant_prices_vat_rate_check,
      ADD CONSTRAINT pricing_variant_prices_vat_rate_check
        CHECK (vat_rate IN ('general', 'reduced'));

    ALTER TABLE pricing_price_history
      DROP CONSTRAINT IF EXISTS pricing_price_history_previous_vat_rate_check,
      ADD CONSTRAINT pricing_price_history_previous_vat_rate_check
        CHECK (previous_vat_rate IS NULL OR previous_vat_rate IN ('general', 'reduced'));

    ALTER TABLE pricing_price_history
      DROP CONSTRAINT IF EXISTS pricing_price_history_new_vat_rate_check,
      ADD CONSTRAINT pricing_price_history_new_vat_rate_check
        CHECK (new_vat_rate IN ('general', 'reduced'));
  `);
};
