-- MySQL Workbench Synchronization
-- Generated: 2019-09-23 12:39
-- Model: SoG
-- Version: 1.3.24
-- 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_asset` 
CHANGE COLUMN `created_by` `created_by` NCHAR(36) NULL DEFAULT NULL ,
CHANGE COLUMN `last_changed_by` `last_changed_by` NCHAR(36) NULL DEFAULT NULL ,
CHANGE COLUMN `deleted_by` `deleted_by` NCHAR(36) NULL DEFAULT NULL ,
CHANGE COLUMN `approved_by` `approved_by` NCHAR(36) NULL DEFAULT NULL ,
CHANGE COLUMN `created_by_key_id` `created_by_key_id` NCHAR(36) NULL DEFAULT NULL ;

ALTER TABLE `sog`.`glam_asset_type` 
CHANGE COLUMN `created_by` `created_by` NCHAR(36) NULL DEFAULT NULL ,
CHANGE COLUMN `last_changed_by` `last_changed_by` NCHAR(36) NULL DEFAULT NULL ,
CHANGE COLUMN `deleted_by` `deleted_by` NCHAR(36) NULL DEFAULT NULL ;

ALTER TABLE `sog`.`glam_device` 
ADD COLUMN `asset_id` INT(11) NULL DEFAULT NULL AFTER `device_state`,
ADD INDEX `fk_glam_device_glam_asset1_idx` (`asset_id` ASC);

ALTER TABLE `sog`.`glam_alarm_log` 
ADD COLUMN `alarm_log_asset_id` INT(11) NULL DEFAULT NULL AFTER `alarm_log_access_point_id`;

ALTER TABLE `sog`.`glam_device` 
ADD CONSTRAINT `fk_glam_device_glam_asset1`
  FOREIGN KEY (`asset_id`)
  REFERENCES `sog`.`glam_asset` (`asset_id`)
  ON DELETE SET NULL
  ON UPDATE NO ACTION;


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