DROP TABLE IF EXISTS `%TABLE_PREFIX%pac_roles`;
CREATE TABLE `%TABLE_PREFIX%pac_roles` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(64) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Roles';

DROP TABLE IF EXISTS `%TABLE_PREFIX%pac_role_includes`;
CREATE TABLE `%TABLE_PREFIX%pac_role_includes` (
  `role_id` bigint(20) unsigned NOT NULL,
  `included_role_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`role_id`, `included_role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Role Includes Map';

DROP TABLE IF EXISTS `%TABLE_PREFIX%pac_users_roles`;
CREATE TABLE `%TABLE_PREFIX%pac_users_roles` (
  `user_id` varchar(96) NOT NULL,
  `role_id` bigint(20) NOT NULL,
  PRIMARY KEY (`user_id`,`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='User Role Map';

DROP TABLE IF EXISTS `%TABLE_PREFIX%pac_roles_destinations_values`;
CREATE TABLE `%TABLE_PREFIX%pac_roles_destinations_values` (
  `destination` varchar(96) NOT NULL,
  `token` varchar(96) NOT NULL,
  `role_id` bigint(20) NOT NULL,
  `value` varchar(96) NOT NULL,
  PRIMARY KEY (`token`,`role_id`,`value`,`destination`),
  KEY `finder` (`destination`,`token`,`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Permission Values';
