CREATE TABLE IF NOT EXISTS `terms_conditions` (
  `serial_tac` INT NOT NULL AUTO_INCREMENT,
  `route_tac` TEXT NULL,
  `date_tac` DATETIME NULL,
  `in_use_tac` ENUM('YES', 'NO') NULL DEFAULT 'YES',
  `status_tac` ENUM('ACTIVE', 'INACTIVE') DEFAULT 'ACTIVE',
  PRIMARY KEY (`serial_tac`))
ENGINE = InnoDB
DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `terms_conditions_user` (
  `serial_tul` INT NOT NULL AUTO_INCREMENT,
  `date_tul` DATETIME NULL,
  `serial_usr` INT(11) NOT NULL,
  `serial_tac` INT NULL,
  `status_tul` ENUM('ACTIVE', 'INACTIVE') NULL DEFAULT 'ACTIVE',
  PRIMARY KEY (`serial_tul`),
  INDEX `fk_terms_conditions_user_user1_idx` (`serial_usr` ASC),
  INDEX `fk_terms_conditions_user_terms_conditions1_idx` (`serial_tac` ASC),
  CONSTRAINT `fk_terms_conditions_user_user1`
    FOREIGN KEY (`serial_usr`)
    REFERENCES `user` (`serial_usr`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_terms_conditions_user_terms_conditions1`
    FOREIGN KEY (`serial_tac`)
    REFERENCES `terms_conditions` (`serial_tac`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

ALTER TABLE `user` ADD COLUMN `serial_tac` INT NULL DEFAULT NULL AFTER `serial_std`,
ADD COLUMN `accept_terms_conditions` ENUM('YES', 'NO') NULL DEFAULT 'NO' AFTER `number_ids`,
ADD INDEX `fk_user_terms_conditions1_idx` (`serial_tac` ASC),
ADD CONSTRAINT `fk_user_terms_conditions1` FOREIGN KEY (`serial_tac`) REFERENCES `terms_conditions` (`serial_tac`);

ALTER TABLE `school_setup` ADD COLUMN `terms_conditions_sst` ENUM('YES', 'NO') NOT NULL DEFAULT 'NO' AFTER `show_without_uniform_attendance_sst`;

INSERT INTO `process` (`serial_prc`, `prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`, `id_exclusion`) VALUES
(626, 52, 'Configuración Términos y Condiciones', 'laravel/public/termsconditions', NULL, 'LOCKABLE', NULL);

INSERT INTO `allowed_pages_by_process` (`serial_prc`, `url_dsc`) VALUES
(626, 'termsconditionscontroller@getindex'),
(626, 'termsconditionscontroller@postcreate'),
(626, 'termsconditionscontroller@getform'),
(626, 'termsconditionscontroller@postform');
