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';

CREATE SCHEMA IF NOT EXISTS `administkmali` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `administkmali` ;

-- -----------------------------------------------------
-- Table `administkmali`.`users`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `administkmali`.`users` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `username` VARCHAR(45) NOT NULL ,
  `password` VARCHAR(255) NOT NULL ,
  `role` ENUM('admin') NOT NULL DEFAULT 'admin' ,
  PRIMARY KEY (`id`) ,
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) ,
  UNIQUE INDEX `username_UNIQUE` (`username` ASC) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `administkmali`.`categories`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `administkmali`.`categories` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `nom` VARCHAR(255) NOT NULL ,
  `slug` VARCHAR(255) NULL ,
  `image` VARCHAR(255) NULL ,
  `ordre` TINYINT NOT NULL ,
  PRIMARY KEY (`id`) ,
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) ,
  UNIQUE INDEX `slug_UNIQUE` (`slug` ASC) ,
  UNIQUE INDEX `nom_UNIQUE` (`nom` ASC) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `administkmali`.`demarches`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `administkmali`.`demarches` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `nom` VARCHAR(255) NOT NULL ,
  `slug` VARCHAR(255) NOT NULL ,
  `description` TEXT NULL ,
  `procedure` TEXT NULL ,
  `documents` TEXT NULL ,
  `couts` TEXT NULL ,
  `delais` TEXT NULL ,
  `services_formulaires` TEXT NULL ,
  `references` TEXT NULL ,
  `services_contact` TEXT NULL ,
  `created` DATETIME NULL ,
  `modified` DATETIME NULL ,
  `categorie_id` INT UNSIGNED NOT NULL ,
  PRIMARY KEY (`id`, `categorie_id`) ,
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) ,
  UNIQUE INDEX `nom_UNIQUE` (`nom` ASC) ,
  UNIQUE INDEX `slug_UNIQUE` (`slug` ASC) ,
  INDEX `fk_demarches_categories_idx` (`categorie_id` ASC) ,
  CONSTRAINT `fk_demarches_categories`
    FOREIGN KEY (`categorie_id` )
    REFERENCES `administkmali`.`categories` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `administkmali`.`actualites`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `administkmali`.`actualites` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `titre` VARCHAR(255) NOT NULL ,
  `slug` VARCHAR(255) NOT NULL ,
  `image` VARCHAR(255) NULL ,
  `contenu` TEXT NULL ,
  `created` DATETIME NULL ,
  `modified` DATETIME NULL ,
  PRIMARY KEY (`id`) ,
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) ,
  UNIQUE INDEX `slug_UNIQUE` (`slug` ASC) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `administkmali`.`editos`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `administkmali`.`editos` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `contenu` TEXT NULL ,
  `created` DATETIME NULL ,
  `modified` DATETIME NULL ,
  PRIMARY KEY (`id`) ,
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) )
ENGINE = InnoDB;

USE `administkmali` ;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
