DROP TABLE IF EXISTS `change_orders`;
CREATE TABLE `change_orders` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `job_id` int(10) unsigned NOT NULL,
  `line_number` smallint(5) unsigned NOT NULL DEFAULT '0',
  `description` varchar(2000) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `date` date DEFAULT NULL,
  `cost` decimal(11,2) unsigned NOT NULL DEFAULT '0.00',
  `chargeable` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `show_on_invoice` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `taxable` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `insert_date` datetime NOT NULL,
  `change_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

alter table jobs add num_change_orders smallint(6) unsigned not null default 0 after step_number;

alter table invoices add change_order_cost decimal(11, 2) unsigned not null default 0 after item_cost;