-- Disable foreign key checks for seeding

-- 1. Insert/Update Users
INSERT INTO users (id, email, password_hash, first_name, last_name, phone, primary_role_id, status, email_verified_at)
VALUES
(1, 'admin@wilddubai.ae', '$2a$12$w7WaPNI1SoXEgrDBJgCAu.kDPEcPzC30DvhoOmtoIva1YV9bM5cdy', 'Ahmad', 'Al-Mansour', '+971501234567', 1, 'active', NOW()),
(100, 'admin@wilddubai.com', '$2a$12$w7WaPNI1SoXEgrDBJgCAu.kDPEcPzC30DvhoOmtoIva1YV9bM5cdy', 'Super', 'Admin', '+971501110001', 1, 'active', NOW()),
(101, 'agent.alex@wilddubai.com', '$2a$12$KmcoctjL/dN0YnNPuVjJ/.xaYqJ02ph2/yo2RVZ.zaGUG/g0Nzun2', 'Alex', 'Sterling', '+971501110002', 4, 'active', NOW()),
(102, 'agency.vanguard@wilddubai.com', '$2a$12$2YRsAIad7Y7NTjfxs/j4c.YYzd9gJBCnlaoEuOzXWdzwkIx8Zc2KG', 'Vanguard', 'Group', '+971501110003', 3, 'active', NOW()),
(103, 'emaar.dev@wilddubai.com', '$2a$12$EsglbQFqUvucA/Re5FFsaOXPPM8afTyx97jT92cvjDDlFf6vCdWeW', 'Emaar', 'Developer', '+971501110004', 2, 'active', NOW()),
(104, 'sheikh.mohammed@luxurymail.ae', '$2a$12$9uH8vMzP9V1vSv.5M5v7A.fdlRjd6w7uvsJQ2YGg/FZ4XIHQn4Xj.', 'Sheikh', 'Mohammed', '+971501110005', 5, 'active', NOW())
ON DUPLICATE KEY UPDATE
  password_hash = VALUES(password_hash),
  first_name    = VALUES(first_name),
  last_name     = VALUES(last_name),
  phone         = VALUES(phone),
  primary_role_id = VALUES(primary_role_id),
  status        = 'active',
  email_verified_at = COALESCE(email_verified_at, NOW());

-- 2. Upsert user_roles
INSERT IGNORE INTO user_roles (user_id, role_id) VALUES
(1, 1),
(100, 1),
(101, 4),
(102, 3),
(103, 2),
(104, 5);

-- 3. Agency entity for vanguard (id=102)
INSERT INTO agencies (id, name, slug, description, email, phone, address, city, orn,
  rera_verification_status, trade_license_number, owner_id, status)
VALUES (10, 'Vanguard Realty Group', 'vanguard-realty-group',
  'Dubai\'s rising force in premium real estate.',
  'agency.vanguard@wilddubai.com', '+971501110003',
  'Office 301, Business Bay Tower, Dubai', 'Dubai',
  'ORN-VGD-2024', 'verified', 'TL-2024-VGD-001', 102, 'active')
ON DUPLICATE KEY UPDATE owner_id = 102, status = 'active';

-- 4. Developer entity for emaar.dev (id=103)
INSERT INTO developers (id, name, slug, description, email, phone,
  headquarters_address, established_year, total_projects_completed,
  total_units_delivered, owner_id, status)
VALUES (10, 'Emaar Premium Corp', 'emaar-premium-corp',
  'Premium property developer with landmark Dubai projects.',
  'emaar.dev@wilddubai.com', '+971501110004',
  'Emaar Business Park, Sheikh Zayed Road, Dubai',
  2010, 12, 4800, 103, 'active')
ON DUPLICATE KEY UPDATE owner_id = 103, status = 'active';

