-- Seed admin users for HoneyDue Admin Panel
-- Run with: ./dev.sh seed-admin (after running migrations)
-- Password is 'password123' hashed with bcrypt

-- Admin Users
-- bcrypt hash for 'password123': $2a$10$KB4rf2NNj0a80lwlwJhaFukE2/THJXbcGZMks7vR3zykyN4zkF6xi
INSERT INTO admin_users (id, email, password, first_name, last_name, role, is_active, created_at, updated_at)
VALUES
    (1, 'admin@honeydue.com', '$2a$10$KB4rf2NNj0a80lwlwJhaFukE2/THJXbcGZMks7vR3zykyN4zkF6xi', 'Admin', 'User', 'super_admin', true, NOW(), NOW())
ON CONFLICT (id) DO UPDATE SET
    email = EXCLUDED.email,
    password = EXCLUDED.password,
    first_name = EXCLUDED.first_name,
    last_name = EXCLUDED.last_name,
    role = EXCLUDED.role,
    is_active = EXCLUDED.is_active,
    updated_at = NOW();

-- Reset sequence to avoid ID conflicts
SELECT setval('admin_users_id_seq', (SELECT COALESCE(MAX(id), 0) + 1 FROM admin_users), false);
