Création script SQL + fonctionnement docker-compose

pull/9/head
Clement FERRERE 3 years ago
parent 514bacd4f6
commit 84ec30f541
  1. 9
      Collaborateur_Epa_Back/docker-compose.yml
  2. 5
      Collaborateur_Epa_Back/espacecollab.backend.api/appsettings.json
  3. 5
      Collaborateur_Epa_Back/espacecollab.backend.sln
  4. 285
      Collaborateur_Epa_Back/init_db.sql

@ -5,11 +5,9 @@ volumes:
services: services:
maria_db: db:
image: "mariadb:10.7.1" image: "mariadb:10.7.1"
restart: always restart: always
ports:
- 3304:3306
environment: environment:
- MYSQL_DATABASE=${DATABASE_NAME} - MYSQL_DATABASE=${DATABASE_NAME}
- MYSQL_USERNAME=${APP_DB_USERNAME} - MYSQL_USERNAME=${APP_DB_USERNAME}
@ -17,6 +15,7 @@ services:
- MYSQL_ROOT_PASSWORD=${APP_DB_ROOT_PASSWORD} - MYSQL_ROOT_PASSWORD=${APP_DB_ROOT_PASSWORD}
volumes: volumes:
- data-volume:/var/lib/mysql - data-volume:/var/lib/mysql
- ./init_db.sql:/docker-entrypoint-initdb.d/init.sql
espacecollab.backend.api: espacecollab.backend.api:
image: ${DOCKER_REGISTRY-}espacecollabbackendapi image: ${DOCKER_REGISTRY-}espacecollabbackendapi
@ -27,9 +26,9 @@ services:
- "5000:80" - "5000:80"
- "5001:443" - "5001:443"
links: links:
- maria_db - db
environment: environment:
- DATABASE_HOSTNAME=maria_db - DATABASE_HOSTNAME=db
- DATABASE_PORT=3306 - DATABASE_PORT=3306
- DATABASE_NAME=${DATABASE_NAME} - DATABASE_NAME=${DATABASE_NAME}
- DATABASE_USERNAME=${APP_DB_USERNAME} - DATABASE_USERNAME=${APP_DB_USERNAME}

@ -7,7 +7,8 @@
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"Sql": { "Sql": {
"LoadFake": true, "LoadFake": false,
"ConnectionString": "server=localhost;user=root;password=root;database=collaborateur_epa" "ConnectionString": "server=db;user=root;password=root;database=collaborateur_epa"
//"ConnectionString": "server=localhost;user=root;password=root;database=collaborateur_epa"
} }
} }

@ -29,6 +29,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "espacecollab.backend.api.te
EndProject EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{815B6ABD-7550-4D79-A53B-E84F4D4A7475}" Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{815B6ABD-7550-4D79-A53B-E84F4D4A7475}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "9 Database", "9 Database", "{4C74D622-BEC1-41C9-95F1-7C44375B531B}"
ProjectSection(SolutionItems) = preProject
init_db.sql = init_db.sql
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU

@ -0,0 +1,285 @@
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='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
CREATE SCHEMA IF NOT EXISTS `collaborateur_epa` DEFAULT CHARACTER SET latin1 ;
USE `collaborateur_epa` ;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`agence`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`agence` (
`Id` INT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(100) NOT NULL,
PRIMARY KEY (`Id`),
UNIQUE INDEX `Name` (`Name` ASC) VISIBLE)
ENGINE = InnoDB
AUTO_INCREMENT = 5
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`businessunit`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`businessunit` (
`Id` INT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(100) NOT NULL,
`AgenceId` INT NOT NULL,
PRIMARY KEY (`Id`),
UNIQUE INDEX `Name` (`Name` ASC) VISIBLE,
INDEX `FK_BUSINESS_UNIT_AGENCE` (`AgenceId` ASC) VISIBLE,
CONSTRAINT `FK_BUSINESS_UNIT_AGENCE`
FOREIGN KEY (`AgenceId`)
REFERENCES `collaborateur_epa`.`agence` (`Id`))
ENGINE = InnoDB
AUTO_INCREMENT = 2
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`collaborateur`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`collaborateur` (
`Id` INT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(100) NOT NULL,
`FirstName` VARCHAR(100) NOT NULL,
`BirthDate` DATE NOT NULL,
`Gender` ENUM('masculin', 'feminin', 'autre') NOT NULL DEFAULT 'masculin',
`Status` ENUM('cadre', 'noncadre', 'alternant', 'stagiaire') NOT NULL DEFAULT 'noncadre',
`ChildrenNumber` SMALLINT NOT NULL,
`Address` VARCHAR(200) NOT NULL,
`Telephone` VARCHAR(15) NOT NULL,
`PersonalMail` VARCHAR(100) NOT NULL,
`ApsideMail` VARCHAR(100) NOT NULL,
`ResignationDate` DATE NULL DEFAULT NULL,
`BusinessUnitId` INT NOT NULL,
`ReferrerId` INT NULL DEFAULT NULL,
PRIMARY KEY (`Id`),
INDEX `FK_COLLABORATEUR_BUSINESSUNIT` (`BusinessUnitId` ASC) VISIBLE,
INDEX `FK_COLLABORATEUR_PARRAIN` (`ReferrerId` ASC) VISIBLE,
CONSTRAINT `FK_COLLABORATEUR_BUSINESSUNIT`
FOREIGN KEY (`BusinessUnitId`)
REFERENCES `collaborateur_epa`.`businessunit` (`Id`),
CONSTRAINT `FK_COLLABORATEUR_PARRAIN`
FOREIGN KEY (`ReferrerId`)
REFERENCES `collaborateur_epa`.`collaborateur` (`Id`))
ENGINE = InnoDB
AUTO_INCREMENT = 13
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`collaborateurappartientbusinessunit`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`collaborateurappartientbusinessunit` (
`CollaborateurId` INT NOT NULL,
`BusinessUnitId` INT NOT NULL,
PRIMARY KEY (`CollaborateurId`, `BusinessUnitId`),
INDEX `FK_BUSINESS_UNIT_COLLABORATEUR` (`BusinessUnitId` ASC) VISIBLE,
CONSTRAINT `FK_BUSINESS_UNIT_COLLABORATEUR`
FOREIGN KEY (`BusinessUnitId`)
REFERENCES `collaborateur_epa`.`businessunit` (`Id`),
CONSTRAINT `FK_COLLABORATEUR_BUSINESS_UNIT`
FOREIGN KEY (`CollaborateurId`)
REFERENCES `collaborateur_epa`.`collaborateur` (`Id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`projet`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`projet` (
`Id` INT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(100) NOT NULL,
`Client` VARCHAR(100) NOT NULL,
`Description` VARCHAR(100) NOT NULL,
`StartingDate` DATE NOT NULL,
`EndingDate` DATE NOT NULL,
PRIMARY KEY (`Id`),
UNIQUE INDEX `Name` (`Name` ASC) VISIBLE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`collaborateurcollaboreprojet`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`collaborateurcollaboreprojet` (
`CollaborateurId` INT NOT NULL,
`ProjetId` INT NOT NULL,
`isManager` TINYINT(1) NOT NULL,
PRIMARY KEY (`CollaborateurId`, `ProjetId`),
INDEX `FK_PROJET_COLLABORE_COLLABORATEUR` (`ProjetId` ASC) VISIBLE,
CONSTRAINT `FK_COLLABORATEUR_COLLABORE_PROJET`
FOREIGN KEY (`CollaborateurId`)
REFERENCES `collaborateur_epa`.`collaborateur` (`Id`),
CONSTRAINT `FK_PROJET_COLLABORE_COLLABORATEUR`
FOREIGN KEY (`ProjetId`)
REFERENCES `collaborateur_epa`.`projet` (`Id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`periodeessai`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`periodeessai` (
`Id` INT NOT NULL AUTO_INCREMENT,
`StartingDate` DATE NOT NULL,
`PlannedEndingDate` DATE NOT NULL,
`RealEndingDate` DATE NOT NULL,
`Comment` VARCHAR(100) NOT NULL,
`Issue` ENUM('VALIDEE', 'PROLONGEE_COLLAB', 'PROLONGEE_APSIDE', 'ARRETEE_COLLAB', 'ARRETEE_APSIDE') NOT NULL,
`CollaborateurId` INT NOT NULL,
PRIMARY KEY (`Id`),
INDEX `FK_COLLABORATEUR_PERIODEESSAI` (`CollaborateurId` ASC) VISIBLE,
CONSTRAINT `FK_COLLABORATEUR_PERIODEESSAI`
FOREIGN KEY (`CollaborateurId`)
REFERENCES `collaborateur_epa`.`collaborateur` (`Id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`collaborateureffectueperiodeessai`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`collaborateureffectueperiodeessai` (
`CollaborateurId` INT NOT NULL,
`PeriodeEssaiId` INT NOT NULL,
PRIMARY KEY (`CollaborateurId`, `PeriodeEssaiId`),
INDEX `FK_PERIODE_ESSAI_COLLABORATEUR` (`PeriodeEssaiId` ASC) VISIBLE,
CONSTRAINT `FK_COLLABORATEUR_PERIODE_ESSAI`
FOREIGN KEY (`CollaborateurId`)
REFERENCES `collaborateur_epa`.`collaborateur` (`Id`),
CONSTRAINT `FK_PERIODE_ESSAI_COLLABORATEUR`
FOREIGN KEY (`PeriodeEssaiId`)
REFERENCES `collaborateur_epa`.`periodeessai` (`Id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`fonction`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`fonction` (
`Id` INT NOT NULL,
`intitule` VARCHAR(100) NOT NULL,
PRIMARY KEY (`Id`),
UNIQUE INDEX `Id` (`Id` ASC) VISIBLE,
UNIQUE INDEX `intitule` (`intitule` ASC) VISIBLE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`collaborateurestfonction`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`collaborateurestfonction` (
`CollaborateurId` INT NOT NULL,
`FonctionId` INT NOT NULL,
PRIMARY KEY (`CollaborateurId`, `FonctionId`),
INDEX `FK_FONCTION_COLLABORATEUR` (`FonctionId` ASC) VISIBLE,
CONSTRAINT `FK_COLLABORATEUR_FONCTION`
FOREIGN KEY (`CollaborateurId`)
REFERENCES `collaborateur_epa`.`collaborateur` (`Id`),
CONSTRAINT `FK_FONCTION_COLLABORATEUR`
FOREIGN KEY (`FonctionId`)
REFERENCES `collaborateur_epa`.`fonction` (`Id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`technologie`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`technologie` (
`Id` INT NOT NULL,
`Name` VARCHAR(100) NOT NULL,
PRIMARY KEY (`Id`),
UNIQUE INDEX `Id` (`Id` ASC) VISIBLE,
UNIQUE INDEX `Name` (`Name` ASC) VISIBLE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`projetutilisetechnologie`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`projetutilisetechnologie` (
`ProjetId` INT NOT NULL,
`TechnologieId` INT NOT NULL,
PRIMARY KEY (`ProjetId`, `TechnologieId`),
INDEX `FK_TECHNOLOGIE_PROJET` (`TechnologieId` ASC) VISIBLE,
CONSTRAINT `FK_PROJET_TECHNOLOGIE`
FOREIGN KEY (`ProjetId`)
REFERENCES `collaborateur_epa`.`projet` (`Id`),
CONSTRAINT `FK_TECHNOLOGIE_PROJET`
FOREIGN KEY (`TechnologieId`)
REFERENCES `collaborateur_epa`.`technologie` (`Id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`referencement`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`referencement` (
`Id` INT NOT NULL AUTO_INCREMENT,
`StartingDate` DATE NOT NULL,
`EndingDate` DATE NOT NULL,
`ReferredId` INT NOT NULL,
`ReferrerId` INT NOT NULL,
PRIMARY KEY (`Id`),
INDEX `FK_COLLABORATEUR_REFERE` (`ReferredId` ASC) VISIBLE,
INDEX `FK_COLLABORATEUR_REFERENT` (`ReferrerId` ASC) VISIBLE,
CONSTRAINT `FK_COLLABORATEUR_REFERE`
FOREIGN KEY (`ReferredId`)
REFERENCES `collaborateur_epa`.`collaborateur` (`Id`),
CONSTRAINT `FK_COLLABORATEUR_REFERENT`
FOREIGN KEY (`ReferrerId`)
REFERENCES `collaborateur_epa`.`collaborateur` (`Id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`site`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`site` (
`Id` INT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(100) NOT NULL,
`Address` VARCHAR(200) NOT NULL,
`BusinessUnitId` INT NOT NULL,
PRIMARY KEY (`Id`),
UNIQUE INDEX `Name` (`Name` ASC) VISIBLE,
INDEX `FK_SITE_BUSINESS_UNIT` (`BusinessUnitId` ASC) VISIBLE,
CONSTRAINT `FK_SITE_BUSINESS_UNIT`
FOREIGN KEY (`BusinessUnitId`)
REFERENCES `collaborateur_epa`.`businessunit` (`Id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `collaborateur_epa`.`sitedeveloppeprojet`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `collaborateur_epa`.`sitedeveloppeprojet` (
`SiteId` INT NOT NULL,
`ProjetId` INT NOT NULL,
PRIMARY KEY (`SiteId`, `ProjetId`),
INDEX `FK_PROJET_SITE` (`ProjetId` ASC) VISIBLE,
CONSTRAINT `FK_PROJET_SITE`
FOREIGN KEY (`ProjetId`)
REFERENCES `collaborateur_epa`.`projet` (`Id`),
CONSTRAINT `FK_SITE_PROJET`
FOREIGN KEY (`SiteId`)
REFERENCES `collaborateur_epa`.`site` (`Id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
Loading…
Cancel
Save