INSERT INTO FundingTypeMaster(id, name) VALUES(3, 'On-lending'),(4, 'Securitization');

ALTER TABLE FundingSource
ADD COLUMN `date_of_contract` DATE NOT NULL AFTER `type_id`,
ADD COLUMN `effective_date` DATE NOT NULL AFTER `date_of_contract`;
UPDATE FundingSource SET date_of_contract=date_of_funding, effective_date=date_of_funding;

CREATE TABLE OnLendingInfo(
   funding_id SMALLINT UNSIGNED NOT NULL,
   office_id SMALLINT UNSIGNED NOT NULL,
   product_id SMALLINT UNSIGNED NOT NULL,
   PRIMARY KEY (funding_id, office_id, product_id),
   FOREIGN KEY (funding_id)
     REFERENCES FundingSource (id)
     ON DELETE NO ACTION
     ON UPDATE CASCADE,
   FOREIGN KEY (office_id)
     REFERENCES Office (id)
     ON DELETE NO ACTION
     ON UPDATE CASCADE,
   FOREIGN KEY (product_id)
     REFERENCES Product (id)
     ON DELETE NO ACTION
     ON UPDATE CASCADE
) ENGINE=InnoDB CHARACTER SET utf8;
