-- phpMyAdmin SQL Dump
-- version 5.2.2
-- https://www.phpmyadmin.net/
--
-- Hôte : uwfieef967.mysql.db
-- Généré le : sam. 22 nov. 2025 à 19:02
-- Version du serveur : 8.0.43-34
-- Version de PHP : 8.1.33

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Base de données : `uwfieef967`
--

-- --------------------------------------------------------

--
-- Structure de la table `campus_activite_log`
--

CREATE TABLE `campus_activite_log` (
  `id` int NOT NULL,
  `user_id` int DEFAULT NULL,
  `username` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `action_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `details` text COLLATE utf8mb4_unicode_ci,
  `success` tinyint(1) NOT NULL DEFAULT '0',
  `ip` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_agent` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Structure de la table `campus_invites`
--

CREATE TABLE `campus_invites` (
  `id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `staff_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `prenom_invite` varchar(100) NOT NULL,
  `nom_invite` varchar(100) NOT NULL,
  `commentaire` text,
  `stand_id` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Structure de la table `campus_login_attempts`
--

CREATE TABLE `campus_login_attempts` (
  `id` int UNSIGNED NOT NULL,
  `ip_address` varchar(45) NOT NULL,
  `attempted_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Structure de la table `campus_nouveaux_arrivants`
--

CREATE TABLE `campus_nouveaux_arrivants` (
  `id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `staff_id` varchar(50) NOT NULL,
  `created_by` int DEFAULT NULL,
  `stand_id` int DEFAULT NULL,
  `repas` enum('oui','non') NOT NULL DEFAULT 'non',
  `boissons` enum('oui','non') NOT NULL DEFAULT 'non',
  `bracelet` enum('oui','non') NOT NULL DEFAULT 'non'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Structure de la table `campus_remplacement_bracelet`
--

CREATE TABLE `campus_remplacement_bracelet` (
  `id` int UNSIGNED NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `staff_id` int NOT NULL,
  `stand_id` int DEFAULT NULL,
  `user_id` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Structure de la table `campus_staff_paleo`
--

CREATE TABLE `campus_staff_paleo` (
  `id` int NOT NULL,
  `qr_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `numero` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `nom` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `prenom` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `secteur_complet` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `commentaire` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Structure de la table `campus_stands`
--

CREATE TABLE `campus_stands` (
  `id` int NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `location` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Structure de la table `campus_users`
--

CREATE TABLE `campus_users` (
  `id` int NOT NULL,
  `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` enum('staff','responsable','statistique') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'staff',
  `stand_id` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Index pour les tables déchargées
--

--
-- Index pour la table `campus_activite_log`
--
ALTER TABLE `campus_activite_log`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_user_id` (`user_id`),
  ADD KEY `idx_username` (`username`),
  ADD KEY `idx_action_type` (`action_type`),
  ADD KEY `idx_created_at` (`created_at`);

--
-- Index pour la table `campus_invites`
--
ALTER TABLE `campus_invites`
  ADD PRIMARY KEY (`id`),
  ADD KEY `staff_id` (`staff_id`),
  ADD KEY `stand_id` (`stand_id`);

--
-- Index pour la table `campus_login_attempts`
--
ALTER TABLE `campus_login_attempts`
  ADD PRIMARY KEY (`id`),
  ADD KEY `ip_time` (`ip_address`,`attempted_at`);

--
-- Index pour la table `campus_nouveaux_arrivants`
--
ALTER TABLE `campus_nouveaux_arrivants`
  ADD PRIMARY KEY (`id`),
  ADD KEY `staff_id` (`staff_id`),
  ADD KEY `created_by` (`created_by`),
  ADD KEY `stand_id` (`stand_id`);

--
-- Index pour la table `campus_remplacement_bracelet`
--
ALTER TABLE `campus_remplacement_bracelet`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_staff` (`staff_id`),
  ADD KEY `idx_stand` (`stand_id`),
  ADD KEY `idx_user` (`user_id`);

--
-- Index pour la table `campus_staff_paleo`
--
ALTER TABLE `campus_staff_paleo`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `campus_stands`
--
ALTER TABLE `campus_stands`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `name` (`name`);

--
-- Index pour la table `campus_users`
--
ALTER TABLE `campus_users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`),
  ADD KEY `stand_id` (`stand_id`);

--
-- AUTO_INCREMENT pour les tables déchargées
--

--
-- AUTO_INCREMENT pour la table `campus_activite_log`
--
ALTER TABLE `campus_activite_log`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `campus_invites`
--
ALTER TABLE `campus_invites`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `campus_login_attempts`
--
ALTER TABLE `campus_login_attempts`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `campus_nouveaux_arrivants`
--
ALTER TABLE `campus_nouveaux_arrivants`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `campus_remplacement_bracelet`
--
ALTER TABLE `campus_remplacement_bracelet`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `campus_staff_paleo`
--
ALTER TABLE `campus_staff_paleo`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `campus_stands`
--
ALTER TABLE `campus_stands`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `campus_users`
--
ALTER TABLE `campus_users`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- Contraintes pour les tables déchargées
--

--
-- Contraintes pour la table `campus_activite_log`
--
ALTER TABLE `campus_activite_log`
  ADD CONSTRAINT `fk_activite_log_user` FOREIGN KEY (`user_id`) REFERENCES `campus_users` (`id`) ON DELETE SET NULL;

--
-- Contraintes pour la table `campus_invites`
--
ALTER TABLE `campus_invites`
  ADD CONSTRAINT `campus_invites_ibfk_1` FOREIGN KEY (`staff_id`) REFERENCES `campus_staff_paleo` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `campus_invites_ibfk_2` FOREIGN KEY (`stand_id`) REFERENCES `campus_stands` (`id`);

--
-- Contraintes pour la table `campus_nouveaux_arrivants`
--
ALTER TABLE `campus_nouveaux_arrivants`
  ADD CONSTRAINT `campus_nouveaux_arrivants_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `campus_users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `campus_nouveaux_arrivants_ibfk_3` FOREIGN KEY (`stand_id`) REFERENCES `campus_stands` (`id`) ON DELETE SET NULL;

--
-- Contraintes pour la table `campus_users`
--
ALTER TABLE `campus_users`
  ADD CONSTRAINT `fk_campus_users_stand` FOREIGN KEY (`stand_id`) REFERENCES `campus_stands` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
