-- Migration: Create Super Admin and System Company -- Description: Inserts the default System Company and Super Admin user. -- Uses unified tables (companies, users, user_roles) -- 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 -- WARNING: This hash is generated WITHOUT PASSWORD_PEPPER. -- For development only. Use seeder-api for proper user creation. -- Password: "Admin@2025!" (should be created by seeder with proper pepper) INSERT INTO users (identifier, password_hash, role, full_name, email, name, status, tenant_id) SELECT 'superadmin', '$2a$10$UWrE9xN39lVagJHlXZsxwOVI3NRSEd1VJ6UzMblW6LOxNmsOZtj9K', -- placeholder, seeder will update 'superadmin', 'Super Administrator', 'admin@gohorsejobs.com', 'Super Administrator', 'active', c.id FROM companies c WHERE c.slug = 'gohorse-system' ON CONFLICT (identifier) DO NOTHING; -- 3. Assign Super Admin Role INSERT INTO user_roles (user_id, role) SELECT u.id, 'SUPER_ADMIN' FROM users u WHERE u.identifier = 'superadmin' ON CONFLICT (user_id, role) DO NOTHING;