text: -- MySQL Script generated by MySQL Workbench
  -- Wed Aug 12 03:28:45 2020
  -- 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 movecore
  -- -----------------------------------------------------
  DROP SCHEMA IF EXISTS `movecore` ;
  
  -- -----------------------------------------------------
  -- Schema movecore
  -- -----------------------------------------------------
  CREATE SCHEMA IF NOT EXISTS `movecore` DEFAULT CHARACTER SET utf8 ;
  USE `movecore` ;
  
  -- -----------------------------------------------------
  -- Table `movecore`.`countries`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `movecore`.`countries` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(45) NOT NULL,
    `slug` VARCHAR(5) NULL,
    PRIMARY KEY (`id`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `movecore`.`cities`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `movecore`.`cities` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(50) NOT NULL,
    `slug` VARCHAR(5) NULL,
    `countries_id` INT NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `fk_cities_countries1_idx` (`countries_id` ASC),
    CONSTRAINT `fk_cities_countries1`
      FOREIGN KEY (`countries_id`)
      REFERENCES `movecore`.`countries` (`id`)
      ON DELETE CASCADE
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `movecore`.`arrondissements`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `movecore`.`arrondissements` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(45) NOT NULL,
    `slug` VARCHAR(45) NULL,
    `cities_id` INT NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `fk_arrondissements_cities_idx` (`cities_id` ASC),
    CONSTRAINT `fk_arrondissements_cities`
      FOREIGN KEY (`cities_id`)
      REFERENCES `movecore`.`cities` (`id`)
      ON DELETE CASCADE
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `movecore`.`quaters`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `movecore`.`quaters` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(45) NULL,
    `arrondissements_id` INT NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `fk_quaters_arrondissements1_idx` (`arrondissements_id` ASC),
    CONSTRAINT `fk_quaters_arrondissements1`
      FOREIGN KEY (`arrondissements_id`)
      REFERENCES `movecore`.`arrondissements` (`id`)
      ON DELETE CASCADE
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `movecore`.`roles`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `movecore`.`roles` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(45) NULL,
    `description` MEDIUMTEXT NULL,
    PRIMARY KEY (`id`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `movecore`.`personals`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `movecore`.`personals` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(45) NOT NULL,
    `birth_date` DATE NULL,
    `login` VARCHAR(45) NULL,
    `password` VARCHAR(255) NULL,
    `tel` VARCHAR(15) NULL,
    `avatar` VARCHAR(255) NULL,
    `roles_id` INT NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `fk_personals_roles1_idx` (`roles_id` ASC),
    CONSTRAINT `fk_personals_roles1`
      FOREIGN KEY (`roles_id`)
      REFERENCES `movecore`.`roles` (`id`)
      ON DELETE CASCADE
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `movecore`.`category_customers`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `movecore`.`category_customers` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(45) NOT NULL,
    `description` MEDIUMTEXT NULL,
    `period` INT NOT NULL COMMENT 'Période ou nombre de jours pour relancer le client.',
    PRIMARY KEY (`id`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `movecore`.`customers`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `movecore`.`customers` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `code` VARCHAR(45) NULL,
    `name` VARCHAR(45) NULL,
    `sex` CHAR(1) NULL,
    `tel` VARCHAR(10) NULL,
    `birthday` DATE NULL,
    `sector` VARCHAR(45) NULL,
    `particular_landmark` VARCHAR(45) NULL COMMENT 'Repère particulier',
    `landmark` VARCHAR(45) NULL COMMENT 'repere',
    `type_gaz` VARCHAR(45) NULL,
    `quaters_id` INT NOT NULL,
    `category_customers_id` INT NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `fk_customers_quaters1_idx` (`quaters_id` ASC),
    UNIQUE INDEX `code_UNIQUE` (`code` ASC),
    INDEX `fk_customers_category_customers1_idx` (`category_customers_id` ASC),
    CONSTRAINT `fk_customers_quaters1`
      FOREIGN KEY (`quaters_id`)
      REFERENCES `movecore`.`quaters` (`id`)
      ON DELETE CASCADE
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_customers_category_customers1`
      FOREIGN KEY (`category_customers_id`)
      REFERENCES `movecore`.`category_customers` (`id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `movecore`.`gaz`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `movecore`.`gaz` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(45) NOT NULL,
    `weight` VARCHAR(45) NOT NULL COMMENT 'Le poids du ',
    `price` INT NULL,
    PRIMARY KEY (`id`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `movecore`.`customer_gaz`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `movecore`.`customer_gaz` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `customer_id` INT NOT NULL,
    `gaz_id` INT NOT NULL,
    `time_order` TIME NULL,
    `date_order` DATE NULL,
    `time_deliver` TIME NULL,
    `status_order` VARCHAR(45) NULL,
    `deliver_delay` VARCHAR(45) NULL COMMENT 'Différence entre time_ordre et  time_deliver',
    `quantity` INT NULL,
    `personals_id` INT NOT NULL,
    INDEX `fk_customers_has_gaz_gaz1_idx` (`gaz_id` ASC),
    INDEX `fk_customers_has_gaz_customers1_idx` (`customer_id` ASC),
    INDEX `fk_customer_gaz_personals1_idx` (`personals_id` ASC),
    PRIMARY KEY (`id`, `customer_id`, `gaz_id`),
    CONSTRAINT `fk_customers_has_gaz_customers1`
      FOREIGN KEY (`customer_id`)
      REFERENCES `movecore`.`customers` (`id`)
      ON DELETE CASCADE
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_customers_has_gaz_gaz1`
      FOREIGN KEY (`gaz_id`)
      REFERENCES `movecore`.`gaz` (`id`)
      ON DELETE CASCADE
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_customer_gaz_personals1`
      FOREIGN KEY (`personals_id`)
      REFERENCES `movecore`.`personals` (`id`)
      ON DELETE CASCADE
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `movecore`.`relauches`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `movecore`.`relauches` (
    `id` INT NOT NULL,
    `statuts` VARCHAR(45) NULL,
    `date` DATE NULL,
    `date_reminder` DATE NULL,
    `customer_gaz_id` INT NOT NULL,
    `customer_gaz_customer_id` INT NOT NULL,
    `customer_gaz_gaz_id` INT NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `fk_relauches_customer_gaz1_idx` (`customer_gaz_id` ASC, `customer_gaz_customer_id` ASC, `customer_gaz_gaz_id` ASC),
    CONSTRAINT `fk_relauches_customer_gaz1`
      FOREIGN KEY (`customer_gaz_id` , `customer_gaz_customer_id` , `customer_gaz_gaz_id`)
      REFERENCES `movecore`.`customer_gaz` (`id` , `customer_id` , `gaz_id`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  SET SQL_MODE=@OLD_SQL_MODE;
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  