DO $$
BEGIN
  CREATE TYPE lending_loan_type_enum AS ENUM ('COMMUNITY_LENDING', 'P2P_LENDING');
EXCEPTION
  WHEN duplicate_object THEN NULL;
END $$;

ALTER TABLE lending_templates
  ADD COLUMN IF NOT EXISTS loan_type lending_loan_type_enum NOT NULL DEFAULT 'P2P_LENDING';

ALTER TABLE lending_opportunities
  ADD COLUMN IF NOT EXISTS loan_type lending_loan_type_enum NOT NULL DEFAULT 'P2P_LENDING';

ALTER TABLE loan_applications
  ADD COLUMN IF NOT EXISTS loan_type lending_loan_type_enum NOT NULL DEFAULT 'P2P_LENDING';
