-- +--------------------------------------------------------------------+
-- | Copyright CiviCRM LLC. All rights reserved.                        |
-- |                                                                    |
-- | This work is published under the GNU AGPLv3 license with some      |
-- | permitted exceptions and without any warranty. For full license    |
-- | and copyright information, see https://civicrm.org/licensing       |
-- +--------------------------------------------------------------------+
--
-- Generated from schema.tpl
-- DO NOT EDIT.  Generated by CRM_Core_CodeGen
--
-- /*******************************************************
-- *
-- * Clean up the existing tables - this section generated from drop.tpl
-- *
-- *******************************************************/



-- /*******************************************************
-- *
-- * Create new tables
-- *
-- *******************************************************/

-- /*******************************************************
-- *
-- * civicrm_role
-- *
-- * A Role holds a set of permissions. Roles may be granted to Users.
-- *
-- *******************************************************/
CREATE TABLE `civicrm_role` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique Role ID',
  `name` varchar(60) NOT NULL COMMENT 'Machine name for this role',
  `label` varchar(128) NOT NULL COMMENT 'Human friendly name for this role',
  `permissions` text NOT NULL COMMENT 'List of permissions granted by this role',
  `is_active` tinyint DEFAULT 1 COMMENT 'Only active roles grant permissions',
  PRIMARY KEY (`id`)
)
ENGINE=InnoDB;

-- /*******************************************************
-- *
-- * civicrm_user
-- *
-- * A standalone user account
-- *
-- *******************************************************/
CREATE TABLE `civicrm_user` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique User ID',
  `contact_id` int unsigned COMMENT 'FK to Contact - possibly redundant',
  `username` varchar(60) NOT NULL,
  `password` varchar(128) NOT NULL COMMENT 'Hashed password',
  `email` varchar(255) NOT NULL COMMENT 'Email (e.g. for password resets)',
  `roles` varchar(128) COMMENT 'FK to Role',
  `when_created` timestamp DEFAULT CURRENT_TIMESTAMP,
  `when_last_accessed` timestamp NULL,
  `when_updated` timestamp NULL,
  `is_active` tinyint NOT NULL DEFAULT 1,
  `timezone` varchar(32) NULL COMMENT 'User\'s timezone',
  `language` int unsigned COMMENT 'The language for the user.',
  PRIMARY KEY (`id`),
  UNIQUE INDEX `UI_username`(username),
  CONSTRAINT FK_civicrm_user_contact_id FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE CASCADE
)
ENGINE=InnoDB;
