SET @next_user_role_type_id = (SELECT max(id)+1 FROM ohrm_user_role_type);
INSERT INTO ohrm_user_role_type (`id`, `name`) VALUES (@next_user_role_type_id, 'Guest');

INSERT INTO `ohrm_user_role` (`name`, `display_name`, `is_assignable`, `is_predefined`, `is_editable`, `type_id`, `deletable`) VALUES
 ('Guest', 'Guest', 0, 1, 0, @next_user_role_type_id, 0);
SET @guest_user_role_id = (SELECT LAST_INSERT_ID());

INSERT INTO `ohrm_user` (user_role_id, emp_number, user_name, user_password, deleted, purged, status) VALUES
(@guest_user_role_id, NULL, '_guest_', NULL, 0, 0, 1);

CREATE TABLE `ohrm_guest_token`
(
    `id`                int unsigned not null auto_increment,
    `name`              varchar(255) not null,
    `email`             varchar(255) not null,
    `token`             varchar(255) not null,
    `home_page`         varchar(255) not null,
    `permissions`   json default null,
    `expires` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    `deleted_at` DATETIME DEFAULT NULL,
    primary key (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
