-- The eight areas specified for the Shaheen Network launch. Additional
-- areas (for this company or any future company) are added as normal
-- rows through the application, not further migrations.
INSERT INTO areas (company_id, area_name, area_code, sort_order)
SELECT c.id, a.area_name, a.area_code, a.sort_order
FROM companies c
CROSS JOIN (
    SELECT 'Chella'          AS area_name, 'CH' AS area_code, 1 AS sort_order UNION ALL
    SELECT 'Shehni',               'SH', 2 UNION ALL
    SELECT 'Maloowal',              'MW', 3 UNION ALL
    SELECT 'Malchan',               'MC', 4 UNION ALL
    SELECT 'Kotli Chandu',          'KC', 5 UNION ALL
    SELECT 'Mamojiyaah',            'MJ', 6 UNION ALL
    SELECT 'Kotli Bhuttah',         'KB', 7 UNION ALL
    SELECT 'Mumarey Malkey',        'MM', 8
) a
WHERE c.company_slug = 'shaheen-network'
  AND NOT EXISTS (
      SELECT 1 FROM areas ex WHERE ex.company_id = c.id AND ex.area_code = a.area_code
  );
