CREATE INDEX IF NOT EXISTS idx_rit_tenant_status ON recurring_invoice_templates (tenant_id, status);
--> statement-breakpoint

DO $$
BEGIN
  IF NOT EXISTS (
    SELECT 1 FROM pg_constraint WHERE conname = 'rit_currency_check'
  ) THEN
    ALTER TABLE recurring_invoice_templates
      ADD CONSTRAINT rit_currency_check
      CHECK (currency IN ('ILS','USD','EUR'));
  END IF;
END $$;
