'use strict';

exports.shorthands = undefined;

exports.up = (pgm) => {
  // Allow 'cancel' operation in inventory_movements for POS-FIX-8 (delete parked sale restores stock)
  pgm.sql(`
    ALTER TABLE inventory_movements
    DROP CONSTRAINT IF EXISTS inventory_movements_operation_check,
    ADD CONSTRAINT inventory_movements_operation_check
      CHECK (operation = ANY (ARRAY['reserve'::text, 'release'::text, 'confirm'::text, 'set_available'::text, 'return'::text, 'cancel'::text]))
  `);
};

exports.down = (pgm) => {
  pgm.sql(`
    ALTER TABLE inventory_movements
    DROP CONSTRAINT IF EXISTS inventory_movements_operation_check,
    ADD CONSTRAINT inventory_movements_operation_check
      CHECK (operation = ANY (ARRAY['reserve'::text, 'release'::text, 'confirm'::text, 'set_available'::text, 'return'::text))
  `);
};
