ALTER TABLE `project_files` ADD `user_id` INT NULL AFTER `type`;
ALTER TABLE `project_files` ADD `building_id` INT NULL AFTER `user_id`, ADD `place_id` INT NULL AFTER `building_id`;
ALTER TABLE `project_materials` ADD `vat` INT NOT NULL DEFAULT '0' AFTER `price`;

ALTER TABLE `users` ADD `credit` DOUBLE(10,2) NOT NULL DEFAULT '0' AFTER `price_per_hour`;
CREATE TABLE `user_credit_log` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `price` double(10,2) 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;

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

ALTER TABLE `user_credit_log`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;
