-- Co-Lite change add-company-scoping: company code and status; INS and CV. -- Target: `service-system`.`company`. Run once, after the release package, before 02 and 03. -- DDL: run with a user that may alter tables, not the services' user. USE `service-system`; ALTER TABLE `company` ADD COLUMN `code` varchar(20) NULL AFTER `name`, ADD COLUMN `status` char(1) NOT NULL DEFAULT 'A' COMMENT 'A active, I inactive' AFTER `code`; -- The existing company (all current data) becomes INS. UPDATE `company` SET `name` = 'INS', `code` = 'ins' WHERE `id` = 1; INSERT INTO `company` (`name`, `code`, `status`) VALUES ('CV', 'cv', 'A'); ALTER TABLE `company` MODIFY COLUMN `code` varchar(20) NOT NULL, ADD UNIQUE KEY `uk_company_code` (`code`);