-- Motorstate Dictionary Migration
-- Run this ONCE before discover_makes_motorstate_dictionary.php
--
-- Step 1: Reset polluted vehicle_make_candidates
-- Step 2: Seed canonical OEM universe into vehicle_makes
-- Step 3: Rebuild vehicle_make_aliases (lowercase)
--
-- If vehicle_makes uses make_name instead of canonical_make, replace
-- canonical_make with make_name in the INSERT and SELECT below.

-- Step 1: Clean candidate table
TRUNCATE TABLE vehicle_make_candidates;

-- Step 2: Seed canonical OEM makes (INSERT IGNORE = no duplicates)
-- Uses canonical_make column (aligns with seed_fitment_regex.php)
INSERT IGNORE INTO vehicle_makes (canonical_make) VALUES
('Ford'),
('Chevrolet'),
('GMC'),
('Toyota'),
('Nissan'),
('Honda'),
('Subaru'),
('Mazda'),
('Mitsubishi'),
('Hyundai'),
('Kia'),
('Volkswagen'),
('Audi'),
('BMW'),
('Mercedes-Benz'),
('Porsche'),
('Volvo'),
('Mini'),
('Jaguar'),
('Land Rover'),
('Tesla'),
('Acura'),
('Infiniti'),
('Lexus'),
('Cadillac'),
('Buick'),
('Chrysler'),
('Dodge'),
('RAM'),
('Jeep'),
('Lincoln'),
('Genesis'),
('Alfa Romeo'),
('Fiat'),
('Scion'),
('Pontiac'),
('Saturn'),
('Hummer'),
('Oldsmobile'),
('Mercury');

-- Step 3: Rebuild alias table (lowercase aliases from canonical makes)
INSERT IGNORE INTO vehicle_make_aliases (make_id, alias)
SELECT id, LOWER(canonical_make)
FROM vehicle_makes;
