-- Migration: Add role-based access control
-- Date: 2026-02-25
-- Description: Change role system from (admin, user) to (admin, dosen, trainee)

-- Step 1: Update existing 'user' records to 'trainee' first
UPDATE users SET role = 'trainee' WHERE role = 'user';

-- Step 2: Update the users table to support new roles
ALTER TABLE users MODIFY COLUMN role ENUM('admin', 'dosen', 'trainee') DEFAULT 'trainee';

-- Step 3: Migration complete - verify
SELECT id, username, full_name, role, specialization FROM users ORDER BY role, full_name;
