-- admin 계정 비밀번호 초기화: admin1234!
INSERT INTO users (login_id, password, user_name, email, status, fail_count, pwd_changed_at, created_at)
VALUES (
    'admin',
    '$2b$10$NClaIICfNMTGWyto9X6gV.yrnYEyiQeakgirWfxRJh.vYfDtubKdu',
    '시스템 관리자',
    'admin@example.com',
    'ACTIVE',
    0,
    NOW(),
    NOW()
)
ON CONFLICT (login_id) DO UPDATE
    SET password    = '$2b$10$NClaIICfNMTGWyto9X6gV.yrnYEyiQeakgirWfxRJh.vYfDtubKdu',
        status      = 'ACTIVE',
        fail_count  = 0;

-- admin → SUPER_ADMIN 권한 매핑
INSERT INTO user_role (user_id, role_id)
SELECT u.user_id, r.role_id
FROM users u, role r
WHERE u.login_id = 'admin' AND r.role_code = 'SUPER_ADMIN'
ON CONFLICT (user_id, role_id) DO NOTHING;
