##生产计划管理增加权限
INSERT into `auth_permission` (name, content_type_id, codename) values
("复核",(select id from django_content_type where app_label = "plan" and model = "productionplan"),"check2_production_plan");
INSERT into `auth_permission` (name, content_type_id, codename) values
("批准",(select id from django_content_type where app_label = "plan" and model = "productionplan"),"check3_production_plan");

##采购合同管理增加权限
INSERT into `auth_permission` (name, content_type_id, codename) values
("复核",(select id from django_content_type where app_label = "purchase" and model = "purchaseorder"),"check2_purchase_order");
INSERT into `auth_permission` (name, content_type_id, codename) values
("批准",(select id from django_content_type where app_label = "purchase" and model = "purchaseorder"),"check3_purchase_order");

##采购计划管理增加权限
INSERT into `auth_permission` (name, content_type_id, codename) values
("复核",(select id from django_content_type where app_label = "purchase" and model = "purchaseplan"),"check2_purchase_plan");
INSERT into `auth_permission` (name, content_type_id, codename) values
("批准",(select id from django_content_type where app_label = "purchase" and model = "purchaseplan"),"check3_purchase_plan");


ALTER TABLE `production_plan`
ADD COLUMN `check_user2_id`  int(11) NULL ,
ADD COLUMN `check_time2`  datetime NULL ,
ADD COLUMN `check_user3_id`  int(11) NULL ,
ADD COLUMN `check_time3`  datetime NULL  ;

ALTER TABLE `purchase_order`
ADD COLUMN `check_user2_id`  int(11) NULL ,
ADD COLUMN `check_time2`  datetime NULL ,
ADD COLUMN `check_user3_id`  int(11) NULL ,
ADD COLUMN `check_time3`  datetime NULL  ;

ALTER TABLE `purchase_plan`
ADD COLUMN `check_user2_id`  int(11) NULL ,
ADD COLUMN `check_time2`  datetime NULL ,
ADD COLUMN `check_user3_id`  int(11) NULL ,
ADD COLUMN `check_time3`  datetime NULL  ;

##同步历史审核数据
UPDATE purchase_plan
set check_time2=check_time,check_user2_id=check_user_id,
 check_time3=check_time,check_user3_id=check_user_id;

UPDATE production_plan
set check_time2=check_time,check_user2_id=check_user_id,
 check_time3=check_time,check_user3_id=check_user_id;

UPDATE purchase_order
set check_time2=check_time,check_user2_id=check_user_id,
 check_time3=check_time,check_user3_id=check_user_id;
