-- Migration to add users table for authentication
CREATE TABLE IF NOT EXISTS users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    nama_lengkap VARCHAR(255),
    role ENUM('admin', 'pengurus') DEFAULT 'admin',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB;

-- Insert default admin user (password: password123)
-- Using password_hash('password123', PASSWORD_DEFAULT) in PHP
INSERT IGNORE INTO users (username, password, nama_lengkap, role) VALUES 
('admin', '$2y$10$314hi5BLY.dImKKtXWRd7.bpTmTTQz3AxKzYCK0tNs0NNr09eIBlK', 'Administrator RT', 'admin');
