CREATE DATABASE IF NOT EXISTS sampmanuali;
USE sampmanuali;

CREATE TABLE IF NOT EXISTS users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS manuals (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    pdf_filename VARCHAR(255) NOT NULL,
    qr_filename VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Default user: admin / admin123 (Please change after login)
INSERT INTO users (username, password) VALUES ('admin', '$2y$10$eBf.W1n6yQ4cNVms1a4RaOut7.JevYkhWZGmX.KXKbT7ubRULQ0X6');
