text: -- MySQL Script generated by MySQL Workbench
  -- 04/21/19 19:16:13
  -- Model: New Model    Version: 1.0
  -- MySQL Workbench Forward Engineering
  
  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,ALLOW_INVALID_DATES';
  
  -- -----------------------------------------------------
  -- Schema softn_cms
  -- -----------------------------------------------------
  
  -- -----------------------------------------------------
  -- Table `profiles`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `profiles` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `profile_name` VARCHAR(45) NOT NULL,
    `profile_description` TEXT NULL,
    `profile_key_name` VARCHAR(45) NOT NULL,
    PRIMARY KEY (`id`))
  ENGINE = InnoDB;
  
  CREATE UNIQUE INDEX `profile_key_name_UNIQUE` ON `profiles` (`profile_key_name` ASC);
  
  
  -- -----------------------------------------------------
  -- Table `users`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `users` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `user_login` VARCHAR(60) NOT NULL COMMENT 'nombre usado para acceder',
    `user_name` VARCHAR(50) NOT NULL COMMENT 'Nombre del usuario',
    `user_email` VARCHAR(100) NOT NULL COMMENT 'Correo electrónico',
    `user_password` VARCHAR(64) NOT NULL COMMENT 'Contraseña',
    `user_registered` DATETIME NOT NULL COMMENT 'Fecha de registro',
    `user_url` VARCHAR(100) NULL,
    `user_url_image` VARCHAR(100) NULL,
    `profile_id` INT NOT NULL,
    PRIMARY KEY (`id`, `profile_id`),
    CONSTRAINT `fk_users_profiles`
      FOREIGN KEY (`profile_id`)
      REFERENCES `profiles` (`id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  CREATE UNIQUE INDEX `user_email_UNIQUE` ON `users` (`user_email` ASC);
  
  CREATE UNIQUE INDEX `user_login_UNIQUE` ON `users` (`user_login` ASC);
  
  CREATE INDEX `fk_users_profile_id` ON `users` (`profile_id` ASC);
  
  
  -- -----------------------------------------------------
  -- Table `settings`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `settings` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `setting_name` VARCHAR(64) NOT NULL,
    `setting_value` LONGTEXT NOT NULL,
    `setting_description` LONGTEXT NULL,
    PRIMARY KEY (`id`))
  ENGINE = InnoDB;
  
  CREATE UNIQUE INDEX `option_name_UNIQUE` ON `settings` (`setting_name` ASC);
  
  
  -- -----------------------------------------------------
  -- Table `permissions`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `permissions` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `permission_name` VARCHAR(45) NOT NULL,
    `permission_description` TEXT NULL,
    `permission_key_name` VARCHAR(45) NOT NULL,
    PRIMARY KEY (`id`))
  ENGINE = InnoDB
  COMMENT = 'Permisos de los usuarios.';
  
  CREATE UNIQUE INDEX `permission_key_name_UNIQUE` ON `permissions` (`permission_key_name` ASC);
  
  
  -- -----------------------------------------------------
  -- Table `profiles_permissions`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `profiles_permissions` (
    `profile_id` INT NOT NULL,
    `permission_id` INT NOT NULL,
    PRIMARY KEY (`profile_id`, `permission_id`),
    CONSTRAINT `fk_profiles_permissions_profiles`
      FOREIGN KEY (`profile_id`)
      REFERENCES `profiles` (`id`)
      ON DELETE CASCADE
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_profiles_permissions_permissions`
      FOREIGN KEY (`permission_id`)
      REFERENCES `permissions` (`id`)
      ON DELETE CASCADE
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  CREATE INDEX `fk_profiles_permissions_permission_id` ON `profiles_permissions` (`permission_id` ASC);
  
  CREATE INDEX `fk_profiles_permissions_profile_id` ON `profiles_permissions` (`profile_id` ASC);
  
  
  SET SQL_MODE=@OLD_SQL_MODE;
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  