-- Seed Data for Auth Learning Database
-- Tables are created by Alembic migrations (001_initial_migration.py)

-- Seed default test user if not exists (password: Test1234)
INSERT INTO users (email, hashed_password, is_active)
VALUES ('test@example.com', '$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW', true)
ON CONFLICT (email) DO NOTHING;

-- Seed sample courses with Russian content covering various topics
DO $$
DECLARE
    test_user_id INTEGER;
BEGIN
    -- Get test user ID
    SELECT id INTO test_user_id FROM users WHERE email = 'test@example.com';
    
    -- Check if courses already exist
    IF NOT EXISTS (SELECT 1 FROM courses LIMIT 1) THEN
        -- Insert sample courses
        INSERT INTO courses (title, description, level, duration, author_id, is_published) VALUES
        (
            'Python Fundamentals',
            'Learn the basics of Python programming language including syntax, data types, and control structures.',
            'beginner',
            20,
            test_user_id,
            true
        ),
        (
            'Web Development with FastAPI',
            'Build modern web applications using FastAPI framework with Python.',
            'intermediate',
            30,
            test_user_id,
            true
        ),
        (
            'Docker for Developers',
            'Master containerization with Docker and Docker Compose for application deployment.',
            'intermediate',
            25,
            test_user_id,
            true
        ),
        (
            'Advanced Algorithms',
            'Deep dive into complex algorithms and data structures for technical interviews.',
            'advanced',
            40,
            test_user_id,
            true
        ),
        (
            'JavaScript Essentials',
            'Learn JavaScript from scratch including ES6+ features and DOM manipulation.',
            'beginner',
            25,
            test_user_id,
            true
        ),
        (
            'Database Design',
            'Learn relational database design principles and SQL optimization techniques.',
            'intermediate',
            35,
            test_user_id,
            true
        ),
        (
            'Machine Learning Basics',
            'Introduction to machine learning concepts and practical implementations.',
            'advanced',
            45,
            test_user_id,
            true
        ),
        (
            'DevOps Practices',
            'Learn continuous integration, deployment, and infrastructure as code.',
            'intermediate',
            30,
            test_user_id,
            true
        ),
        (
            'React Frontend Development',
            'Build modern user interfaces with React library and hooks.',
            'intermediate',
            35,
            test_user_id,
            true
        ),
        (
            'System Architecture',
            'Design scalable and maintainable software system architectures.',
            'advanced',
            50,
            test_user_id,
            true
        );
    END IF;
END $$;