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,ALLOW_INVALID_DATES';

ALTER TABLE `sog`.`glam_domain` ADD COLUMN `point_id` CHAR(36) NULL DEFAULT NULL  AFTER `in_lockdown` , 
  ADD CONSTRAINT `fk_glam_domain_glam_point1`
  FOREIGN KEY (`point_id` )
  REFERENCES `sog`.`glam_point` (`point_id` )
  ON DELETE SET NULL
  ON UPDATE CASCADE
, ADD INDEX `fk_glam_domain_glam_point1_idx` (`point_id` ASC) ;

ALTER TABLE `sog`.`glam_access_point` ADD COLUMN `gsm_coverage` ENUM('UNKNOWN','POOR','GOOD') NULL DEFAULT 'GOOD'  AFTER `ap_movement_alarm_enabled` ;

ALTER TABLE `sog`.`glam_transaction` ADD COLUMN `point_id` CHAR(36) NULL DEFAULT NULL  AFTER `transaction_group_id` , 
  ADD CONSTRAINT `fk_glam_transaction_glam_point1`
  FOREIGN KEY (`point_id` )
  REFERENCES `sog`.`glam_point` (`point_id` )
  ON DELETE SET NULL
  ON UPDATE CASCADE
, ADD INDEX `fk_glam_transaction_glam_point1_idx` (`point_id` ASC) ;

ALTER TABLE `sog`.`glam_transaction_schedule` ADD COLUMN `is_dynamic` BIT(1) NULL DEFAULT b'0'  AFTER `last_changed_on` , 
  ADD CONSTRAINT `fk_objholder`
  FOREIGN KEY (`user_id` )
  REFERENCES `sog`.`glam_objholder` (`user_id` )
  ON DELETE CASCADE
  ON UPDATE CASCADE
, ADD INDEX `fk_objholder_idx` (`user_id` ASC) ;

ALTER TABLE `sog`.`glam_his_access_point` ADD COLUMN `gsm_coverage` ENUM('UNKNOWN','POOR','GOOD') NULL DEFAULT 'GOOD'  AFTER `ap_movement_alarm_enabled` ;

ALTER TABLE `sog`.`glam_his_transaction` ADD COLUMN `point_id` CHAR(36) NULL DEFAULT NULL  AFTER `transaction_group_id` ;

ALTER TABLE `sog`.`glam_his_transaction_schedule` ADD COLUMN `is_dynamic` BIT(1) NULL DEFAULT b'0'  AFTER `last_changed_on` ;

ALTER TABLE `sog`.`glam_supervisor_schedule` CHANGE COLUMN `transaction_location` `transaction_location` POINT NULL  ;

ALTER TABLE `sog`.`glam_point` CHANGE COLUMN `point_location` `point_location` POINT NULL  , ADD COLUMN `location_required` BIT(1) NULL DEFAULT b'1'  AFTER `last_changed_by` , ADD COLUMN `grace_period_start` INT(11) NULL DEFAULT 0  AFTER `location_required` , ADD COLUMN `grace_period_end` INT(11) NULL DEFAULT 0  AFTER `grace_period_start` , ADD COLUMN `gsm_coverage` ENUM('UNKNOWN','POOR','GOOD') NULL DEFAULT 'GOOD'  AFTER `grace_period_end` ;


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