DROP TABLE IF EXISTS `roadshow_dealer`;
CREATE TABLE `roadshow_dealer` (
  `PK_roadshow_dealer_id` int(11) NOT NULL,
  `FK_roadshow_distributor_id` int(11) NOT NULL,
  `libelle_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL,
  `district_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL,
  `code_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL,
  `adresse1_roadshow_dealer` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `adresse2_roadshow_dealer` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `code_postal_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `ville_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `FK_pays_id_roadshow_dealer` int(11) NOT NULL DEFAULT '0',
  `valide_roadshow_dealer` int(1) NOT NULL DEFAULT '0',
  `civilite_other_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `email_other_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `function_other_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `nom_other_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `prenom_other_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `tel1_other_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `tel2_other_roadshow_dealer` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `comment_roadshow_dealer` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `actif_roadshow_dealer` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `roadshow_dealer_session`;
CREATE TABLE `roadshow_dealer_session` (
  `PK_roadshow_dealer_session_id` int(11) NOT NULL,
  `FK_roadshow_dealer_id` int(11) NOT NULL,
  `FK_roadshow_session_id` int(11) NOT NULL,
  `number_client` int(11) NOT NULL DEFAULT '0',
  `number_prospect` int(11) NOT NULL DEFAULT '0',
  `valide_roadshow_dealer_session` int(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `roadshow_distributor`;
CREATE TABLE `roadshow_distributor` (
  `PK_roadshow_distributor_id` int(11) NOT NULL,
  `FK_users_id` int(11) NOT NULL,
  `libelle_roadshow_distributor` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL,
  `civilite_chief_roadshow_distributor` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `email_chief_roadshow_distributor` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `nom_chief_roadshow_distributor` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `prenom_chief_roadshow_distributor` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `tel1_chief_roadshow_distributor` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `tel2_chief_roadshow_distributor` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `nom_resp_roadshow_distributor` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `prenom_resp_roadshow_distributor` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `nom_part_roadshow_distributor` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `prenom_part_roadshow_distributor` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `actif_roadshow_distributor` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `roadshow_racetrack`;
CREATE TABLE `roadshow_racetrack` (
  `PK_roadshow_racetrack_id` int(11) NOT NULL,
  `libelle_roadshow_racetrack` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL,
  `adresse` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `adresse1` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `code_postal` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `ville` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `FK_pays_id` int(11) NOT NULL DEFAULT '0',
  `description` text COLLATE utf8mb4_unicode_ci,
  `actif_roadshow_racetrack` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `roadshow_session`;
CREATE TABLE `roadshow_session` (
  `PK_roadshow_session_id` int(11) NOT NULL,
  `FK_roadshow_racetrack_id` int(11) NOT NULL,
  `quota_roadshow_session` int(11) NOT NULL DEFAULT '0',
  `date_deb_roadshow_session` date NOT NULL DEFAULT '0000-00-00',
  `date_fin_roadshow_session` date NOT NULL DEFAULT '0000-00-00',
  `heure_deb_roadshow_session` time NOT NULL DEFAULT '00:00:00',
  `heure_fin_roadshow_session` time NOT NULL DEFAULT '00:00:00',
  `blocked_roadshow_session` int(1) NOT NULL DEFAULT '0',
  `blocked_why_roadshow_session` text COLLATE utf8mb4_unicode_ci,
  `actif_roadshow_session` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `roadshow_vehicle`;
CREATE TABLE `roadshow_vehicle` (
  `PK_roadshow_vehicle_id` int(11) NOT NULL,
  `FK_roadshow_vehicle_type_id` int(11) NOT NULL,
  `libelle_roadshow_vehicle` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL,
  `motor_roadshow_vehicle` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `registration_roadshow_vehicle` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL,
  `code_roadshow_vehicle` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `chassis_roadshow_vehicle` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `ext_roadshow_vehicle` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `in_roadshow_vehicle` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `actif_roadshow_vehicle` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `roadshow_vehicle_type`;
CREATE TABLE `roadshow_vehicle_type` (
  `PK_roadshow_vehicle_type_id` int(11) NOT NULL,
  `FK_roadshow_vehicle_view_id` int(11) NOT NULL,
  `libelle_roadshow_vehicle_type` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL,
  `actif_roadshow_vehicle_type` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `roadshow_vehicle_view`;
CREATE TABLE `roadshow_vehicle_view` (
  `PK_roadshow_vehicle_view_id` int(11) NOT NULL,
  `libelle_roadshow_vehicle_view` varchar(220) COLLATE utf8mb4_unicode_ci NOT NULL,
  `actif_roadshow_vehicle_view` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


ALTER TABLE `roadshow_dealer`
  ADD PRIMARY KEY (`PK_roadshow_dealer_id`),
  ADD KEY `actif_roadshow_dealer` (`actif_roadshow_dealer`),
  ADD KEY `libelle_roadshow_dealer` (`libelle_roadshow_dealer`),
  ADD KEY `FK_users_id` (`FK_roadshow_distributor_id`);

ALTER TABLE `roadshow_dealer_session`
  ADD PRIMARY KEY (`PK_roadshow_dealer_session_id`),
  ADD KEY `FK_roadshow_dealer_id` (`FK_roadshow_dealer_id`),
  ADD KEY `FK_roadshow_session_id` (`FK_roadshow_session_id`),
  ADD KEY `valide_roadshow_dealer_session` (`valide_roadshow_dealer_session`);

ALTER TABLE `roadshow_distributor`
  ADD PRIMARY KEY (`PK_roadshow_distributor_id`),
  ADD KEY `FK_users_id` (`FK_users_id`),
  ADD KEY `actif_roadshow_distributor` (`actif_roadshow_distributor`);

ALTER TABLE `roadshow_racetrack`
  ADD PRIMARY KEY (`PK_roadshow_racetrack_id`),
  ADD KEY `libelle_roadshow_racetrack` (`libelle_roadshow_racetrack`),
  ADD KEY `actif_roadshow_racetrack` (`actif_roadshow_racetrack`),
  ADD KEY `FK_pays_id` (`FK_pays_id`);

ALTER TABLE `roadshow_session`
  ADD PRIMARY KEY (`PK_roadshow_session_id`),
  ADD KEY `FK_roadshow_racetrack_id` (`FK_roadshow_racetrack_id`),
  ADD KEY `date_deb_roadshow_session` (`date_deb_roadshow_session`),
  ADD KEY `heure_deb_roadshow_session` (`heure_deb_roadshow_session`),
  ADD KEY `blocked_roadshow_session` (`blocked_roadshow_session`),
  ADD KEY `actif_roadshow_session` (`actif_roadshow_session`);

ALTER TABLE `roadshow_vehicle`
  ADD PRIMARY KEY (`PK_roadshow_vehicle_id`),
  ADD KEY `FK_roadshow_vehicle_type_id` (`FK_roadshow_vehicle_type_id`),
  ADD KEY `libelle_roadshow_vehicle` (`libelle_roadshow_vehicle`),
  ADD KEY `actif_roadshow_vehicle` (`actif_roadshow_vehicle`);

ALTER TABLE `roadshow_vehicle_type`
  ADD PRIMARY KEY (`PK_roadshow_vehicle_type_id`),
  ADD KEY `libelle_roadshow_vehicle` (`libelle_roadshow_vehicle_type`),
  ADD KEY `actif_roadshow_vehicle` (`actif_roadshow_vehicle_type`),
  ADD KEY `FK_roadshow_vehicle_view_id` (`FK_roadshow_vehicle_view_id`);

ALTER TABLE `roadshow_vehicle_view`
  ADD PRIMARY KEY (`PK_roadshow_vehicle_view_id`),
  ADD KEY `libelle_roadshow_vehicle` (`libelle_roadshow_vehicle_view`),
  ADD KEY `actif_roadshow_vehicle` (`actif_roadshow_vehicle_view`);


ALTER TABLE `roadshow_dealer`
  MODIFY `PK_roadshow_dealer_id` int(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE `roadshow_dealer_session`
  MODIFY `PK_roadshow_dealer_session_id` int(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE `roadshow_distributor`
  MODIFY `PK_roadshow_distributor_id` int(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE `roadshow_racetrack`
  MODIFY `PK_roadshow_racetrack_id` int(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE `roadshow_session`
  MODIFY `PK_roadshow_session_id` int(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE `roadshow_vehicle`
  MODIFY `PK_roadshow_vehicle_id` int(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE `roadshow_vehicle_type`
  MODIFY `PK_roadshow_vehicle_type_id` int(11) NOT NULL AUTO_INCREMENT;

ALTER TABLE `roadshow_vehicle_view`
  MODIFY `PK_roadshow_vehicle_view_id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;
