-- OPEN_LEARNER: learner role with STUDENT-like RBAC but without LMS sequential prerequisite locks (handled in app code).

CREATE EXTENSION IF NOT EXISTS pgcrypto;

INSERT INTO roles (name, description, is_system) VALUES
    (
        'OPEN_LEARNER',
        'Learner with full LMS catalog access without sequential prerequisite locking',
        TRUE
    )
ON CONFLICT (name) DO NOTHING;

-- Demo OPEN_LEARNER (customer-login): openlearner@yimaru.com / password@123
INSERT INTO users (
    id,
    first_name,
    last_name,
    gender,
    birth_day,
    email,
    phone_number,
    role,
    password,
    age_group,
    education_level,
    country,
    region,
    knowledge_level,
    nick_name,
    occupation,
    learning_goal,
    language_goal,
    language_challange,
    favourite_topic,
    initial_assessment_completed,
    email_verified,
    phone_verified,
    status,
    last_login,
    profile_completed,
    profile_picture_url,
    preferred_language,
    created_at,
    updated_at
)
VALUES
(
    13,
    'Demo',
    'OpenLearner',
    'Female',
    '1999-06-01',
    'openlearner@yimaru.com',
    NULL,
    'OPEN_LEARNER',
    crypt('password@123', gen_salt('bf'))::bytea,
    '25_34',
    'Bachelor',
    'Ethiopia',
    'Addis Ababa',
    'BEGINNER',
    'OpenLearner',
    'Tester',
    'Preview LMS content without sequential locks',
    'English',
    'Grammar',
    'Technology',
    FALSE,
    TRUE,
    FALSE,
    'ACTIVE',
    NULL,
    FALSE,
    NULL,
    'en',
    CURRENT_TIMESTAMP,
    NULL
)
ON CONFLICT (id) DO NOTHING;
