-- Database initialization for mkconstruction
CREATE DATABASE IF NOT EXISTS mkconstruction;
USE mkconstruction;

-- Create the admins table if it doesn't exist
CREATE TABLE IF NOT EXISTS `admins` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Insert a default admin user. 
-- Username: admin
-- Password: password123 (hashed with BCRYPT)
INSERT IGNORE INTO `admins` (`id`, `username`, `password`, `created_at`) VALUES
(1, 'admin', '$2y$10$cc71hX4mWU4c0YgSx4fMCeWFUSbv9CuGCsNI5kYTL6da95nKXWV9K', current_timestamp());
