-- MySQL Workbench Synchronization
-- Generated: 2016-06-21 10:56
-- Model: SoG
-- Version: 1.3.12
-- Project: GLam
-- Author: JaX

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_ext_exam_center` 
CHANGE COLUMN `center_abbreviation` `center_abbreviation` VARCHAR(16) NULL DEFAULT NULL ,
ADD COLUMN `center_email` VARCHAR(64) NULL DEFAULT NULL AFTER `his_id`;

ALTER TABLE `sog`.`glam_ext_exam_timetable` 
CHANGE COLUMN `table_abbreviation` `table_abbreviation` VARCHAR(16) NULL DEFAULT NULL ;

CREATE TABLE IF NOT EXISTS `sog`.`glam_ao_schedule` (
  `id` CHAR(36) NOT NULL,
  `access_object_id` CHAR(36) NOT NULL,
  `access_point_id` CHAR(36) NULL DEFAULT NULL,
  `user_id` CHAR(36) NULL DEFAULT NULL,
  `transaction_id` CHAR(36) NULL DEFAULT NULL,
  `download_status` ENUM('UNKOWN', 'NEW', 'UPDATED', 'PENDING', 'OLD', 'CONFIRMED') NULL DEFAULT 'NEW',
  `last_changed_on` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `transaction_diff` VARCHAR(128) NULL DEFAULT NULL,
  `unsafe_schedule` BIT(1) NULL DEFAULT b'0',
  `transaction_diff_new` VARCHAR(128) NULL DEFAULT NULL,
  `trans_start` INT(11) NULL DEFAULT NULL,
  `trans_end` INT(11) NULL DEFAULT NULL,
  `trans_longitude` FLOAT(11) NULL DEFAULT NULL,
  `trans_latitude` FLOAT(11) NULL DEFAULT NULL,
  `trans_radius` FLOAT(11) NULL DEFAULT NULL,
  `trans_operation` ENUM('ACCESS', 'COMMISSION', 'ACCESS_COMMISSION', 'LOCK_REPLACEMENT', 'LATCH_REPLACEMENT') NULL DEFAULT NULL,
  `trans_ap_serial` INT(11) NULL DEFAULT NULL,
  `trans_ap_rf_id` MEDIUMTEXT NULL DEFAULT NULL,
  `transaction_diff_blob` BLOB NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_glam_ao_schedules_glam_access_object_key1_idx` (`access_object_id` ASC),
  INDEX `fk_glam_ao_schedule_glam_access_point1_idx` (`access_point_id` ASC),
  INDEX `fk_glam_ao_schedule_glam_objholder1_idx` (`user_id` ASC),
  INDEX `fk_glam_ao_schedule_glam_transaction1_idx` (`transaction_id` ASC),
  CONSTRAINT `fk_glam_ao_schedules_glam_access_object_key1`
    FOREIGN KEY (`access_object_id`)
    REFERENCES `sog`.`glam_access_object_key` (`access_object_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_glam_ao_schedule_glam_access_point1`
    FOREIGN KEY (`access_point_id`)
    REFERENCES `sog`.`glam_access_point` (`access_point_id`)
    ON DELETE SET NULL
    ON UPDATE CASCADE,
  CONSTRAINT `fk_glam_ao_schedule_glam_objholder1`
    FOREIGN KEY (`user_id`)
    REFERENCES `sog`.`glam_objholder` (`user_id`)
    ON DELETE SET NULL
    ON UPDATE CASCADE,
  CONSTRAINT `fk_glam_ao_schedule_glam_transaction1`
    FOREIGN KEY (`transaction_id`)
    REFERENCES `sog`.`glam_transaction` (`transaction_id`)
    ON DELETE SET NULL
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;

START TRANSACTION;
USE `sog`;
INSERT INTO `sog`.`versioning` (version_name, version_desc, version, version_string) values ('database', 'Database version',66316,'1.3.12');

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