-- Sauvegarde de la base de données `dbs13765622` - 2026-06-18_11-10-31

DROP TABLE IF EXISTS `admins`;
CREATE TABLE `admins` (
  `id` int NOT NULL AUTO_INCREMENT,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `role` enum('Admin','SuperAdmin') NOT NULL DEFAULT 'Admin',
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

DROP TABLE IF EXISTS `events`;
CREATE TABLE `events` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `event_date` date NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `places_disponibles` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

INSERT INTO `events` VALUES
('1', 'CDL 25', '2025-01-01', '2025-01-29 13:38:46', '0'),
('2', 'CDL 26', '2025-02-27', '2025-01-30 13:04:12', '197');

DROP TABLE IF EXISTS `reservations`;
CREATE TABLE `reservations` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL,
  `event_id` int NOT NULL,
  `guest_count` int NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `status` enum('Confirmée','Annulée') DEFAULT 'Confirmée',
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `event_id` (`event_id`),
  CONSTRAINT `reservations_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `reservations_ibfk_2` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

INSERT INTO `reservations` VALUES
('1', '1', '1', '3', '2025-01-29 13:48:02', 'Annulée'),
('2', '1', '2', '5', '2025-01-30 13:04:22', 'Confirmée'),
('3', '1', '2', '1', '2025-01-30 13:10:46', 'Confirmée'),
('4', '5', '2', '2', '2025-01-30 13:10:55', 'Confirmée');

DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `id` int NOT NULL AUTO_INCREMENT,
  `nom` varchar(50) NOT NULL,
  `prenom` varchar(50) NOT NULL,
  `email` varchar(100) NOT NULL,
  `telephone` varchar(20) NOT NULL,
  `date_naissance` date NOT NULL,
  `type` enum('Guest','Invité') DEFAULT 'Invité',
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

INSERT INTO `users` VALUES
('1', 'Zolger', 'Thomas', 'xarus06@gmail.com', '0774965211', '1991-05-25', 'Invité'),
('5', 'Garnier', 'Laurent', 'nash007@orange.fr', '0609334437', '1971-11-01', 'Invité'),
('6', 'Mag', 'Sky', 'magsky@magsky.com', '0782694411', '1978-01-01', 'Invité'),
('7', 'Truffe', 'Jean de la ', 'truffemoila@gmail.com', '0669696969', '1969-01-10', 'Invité'),
('8', 'Vieux', 'Vérin', 'vieuxverin@vieuxverin.com', '0123456789', '1901-01-01', 'Invité'),
('9', 'V', 'Nico', 'vidardmattei@hotmail.fr', '0615876907', '1980-05-19', 'Invité'),
('10', 'Fabre ', 'Magali ', 'magalifabre1@icloud.com', '0607817372', '1978-11-06', 'Invité'),
('13', 'Roussel', 'Dumont', 'pierre55@approject.net', '460229418', '0000-00-00', 'Invité');

