SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

ALTER TABLE `sog`.`glam_his_ext_exam_schedule_ap` 
DROP FOREIGN KEY `fk_glam_his_ext_exam_schedule_ap_glam_his_ext_exam_schedule1`;

ALTER TABLE `sog`.`glam_his_ext_exam_schedule_oh` 
DROP FOREIGN KEY `fk_glam_his_ext_exam_schedule_oh_glam_his_ext_exam_schedule1`;

ALTER TABLE `sog`.`glam_his_ext_exam_schedule` 
CHANGE COLUMN `his_id` `his_id` BIGINT(20) NOT NULL AUTO_INCREMENT ;

ALTER TABLE `sog`.`glam_his_ext_exam_schedule_ap` 
CHANGE COLUMN `exam_schedule_his_id` `exam_schedule_his_id` BIGINT(20) NOT NULL ,
ADD COLUMN `his_id` BIGINT(20) NOT NULL AUTO_INCREMENT FIRST,
DROP PRIMARY KEY,
ADD PRIMARY KEY (`his_id`);

ALTER TABLE `sog`.`glam_his_ext_exam_schedule_oh` 
CHANGE COLUMN `exam_schedule_his_id` `exam_schedule_his_id` BIGINT(20) NOT NULL ,
CHANGE COLUMN `last_changed_on` `last_changed_on` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
ADD COLUMN `his_id` BIGINT(20) NOT NULL AUTO_INCREMENT FIRST,
DROP PRIMARY KEY,
ADD PRIMARY KEY (`his_id`);

ALTER TABLE `sog`.`glam_his_ext_exam_schedule_ap` 
ADD CONSTRAINT `fk_glam_his_ext_exam_schedule_ap_glam_his_ext_exam_schedule1`
  FOREIGN KEY (`exam_schedule_his_id`)
  REFERENCES `sog`.`glam_his_ext_exam_schedule` (`his_id`)
  ON DELETE CASCADE
  ON UPDATE CASCADE;

ALTER TABLE `sog`.`glam_his_ext_exam_schedule_oh` 
ADD CONSTRAINT `fk_glam_his_ext_exam_schedule_oh_glam_his_ext_exam_schedule1`
  FOREIGN KEY (`exam_schedule_his_id`)
  REFERENCES `sog`.`glam_his_ext_exam_schedule` (`his_id`)
  ON DELETE CASCADE
  ON UPDATE CASCADE;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
