-- Migration: Create Super Admin and System Company
-- Description: Inserts the default System Company and Super Admin user.
-- Uses unified tables (companies, users, user_roles)
-- NOTE: This runs before migration 020 adds extra columns, so only use existing columns

-- 1. Insert System Company (for SuperAdmin context)
INSERT INTO companies (name, slug, type, document, email, description, verified, active)
VALUES (
    'GoHorse System',
    'gohorse-system',
    'system',
    '00.000.000/0001-91',
    'admin@gohorsejobs.com',
    '{"tagline": "System Administration Tenant"}',
    true,
    true
) ON CONFLICT (slug) DO NOTHING;

-- 2. Insert Super Admin User (using only columns from migration 001)
-- WARNING: This hash is generated WITHOUT PASSWORD_PEPPER.
-- For development only. Use seeder-api for proper user creation with pepper.
INSERT INTO users (identifier, password_hash, role, full_name, active)
VALUES (
    'superadmin',
    '$2a$10$UWrE9xN39lVagJHlXZsxwOVI3NRSEd1VJ6UzMblW6LOxNmsOZtj9K', -- placeholder
    'superadmin',
    'Super Administrator',
    true
) ON CONFLICT (identifier) DO NOTHING;

-- NOTE: user_roles table is created in migration 020, so we skip role assignment here.
-- The seeder-api will handle proper user creation with all fields.
