ALTER TABLE public.count_invoices DROP CONSTRAINT count_invoices_un;
CREATE UNIQUE INDEX count_invoices_reference_idx ON public.count_invoices (reference,proforma,credit_note);
