-- Migration: Add last_negotiated date to vendors table
-- Bug & Tweak Sprint

DO $$
DECLARE
  tenant_schema TEXT;
BEGIN
  FOR tenant_schema IN
    SELECT schema_name FROM shared.organizations WHERE schema_name IS NOT NULL
  LOOP
    EXECUTE format(
      'ALTER TABLE %I.vendors ADD COLUMN IF NOT EXISTS last_negotiated DATE',
      tenant_schema
    );
  END LOOP;
END $$;
