-- Create database (run once if not exists)
CREATE DATABASE IF NOT EXISTS `test_login_app` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE `test_login_app`;

-- Users table
CREATE TABLE IF NOT EXISTS `users` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(100) NOT NULL,
  `email` VARCHAR(190) NOT NULL UNIQUE,
  `password_hash` VARCHAR(255) NOT NULL,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Seed an admin user (email: admin@example.com, password: admin123)
INSERT INTO `users` (`name`, `email`, `password_hash`) VALUES (
  'Admin',
  'admin@example.com',
  -- PHP: password_hash('admin123', PASSWORD_DEFAULT)
  '$2y$10$1vVb3l7e9dLEzHnJ6qmsY.1C8b3iK4eY9k2P0g4Rk3f5hY7W2oY1G'
) ON DUPLICATE KEY UPDATE email = email;
