alter table purchase_orders add created_from_rfq_id int unsigned null after job_id;

-- add log_job_history table
CREATE TABLE `log_job_history` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `job_id` int(11) unsigned NOT NULL,
  `message` varchar(2000) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `rfq_related` tinyint(4) unsigned NOT NULL DEFAULT '0',
  `rfq_id` int(11) unsigned NULL,
  `quote_letter_related` tinyint(4) unsigned NOT NULL DEFAULT '0',
  `purchase_order_related` tinyint(4) unsigned NOT NULL DEFAULT '0',
  `purchase_order_id` int(11) unsigned NOT NULL,
  `invoice_related` tinyint(4) unsigned NOT NULL DEFAULT '0',
  `insert_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

insert into log_job_history (job_id, message, insert_date)
select id, concat('Job # ', number, ' created'), insert_date from jobs;