CREATE DATABASE IF NOT EXISTS `cms` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
USE `cms`;

CREATE TABLE IF NOT EXISTS `utilisateur` (
  `id` int AUTO_INCREMENT PRIMARY KEY,
  `login` varchar(50) NOT NULL UNIQUE,
  `password` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `articles` (
  `id` int AUTO_INCREMENT PRIMARY KEY,
  `titre` varchar(255) NOT NULL,
  `contenu` text NOT NULL,
  `date_creation` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Admin par défaut (mot de passe : admin123)
INSERT INTO `utilisateur` (`login`, `password`) VALUES
('admin', '$2y$10$wXQTzJxAJdiVV5C.fC00GO8lGpAIAo3b5hzXC7ANpFOQeIaQvoBj.');