ALTER TABLE `project_works` ADD `vat` TINYINT NOT NULL DEFAULT '0' AFTER `quantity_unit`;
UPDATE `project_works` SET vat = 27;

CREATE TABLE `project_certificates` (
  `id` int(11) NOT NULL,
  `project_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `project_certificate_works` (
  `project_certificate_id` int(11) NOT NULL,
  `project_work_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `project_certificates`
  ADD PRIMARY KEY (`id`),
  ADD KEY `project_id` (`project_id`),
  ADD KEY `user_id` (`user_id`);

ALTER TABLE `project_certificate_works`
  ADD PRIMARY KEY (`project_certificate_id`,`project_work_id`);

ALTER TABLE `project_certificates`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
COMMIT;

ALTER TABLE `project_certificates` ADD `subject` VARCHAR(100) NOT NULL AFTER `user_id`, ADD `finish_date` DATE NOT NULL AFTER `subject`, ADD `payment_days` INT(1) NOT NULL AFTER `finish_date`, ADD `payment_mode` TINYINT(1) NOT NULL AFTER `payment_days`, ADD `contract_number` VARCHAR(100) NOT NULL AFTER `payment_mode`, ADD `representative_1` VARCHAR(100) NOT NULL AFTER `contract_number`, ADD `representative_2` VARCHAR(100) NOT NULL AFTER `representative_1`;