-- Plate-to-vehicle lookup table (tenant DB)
-- Allows instant vehicle identification from Mexican license plates.

CREATE TABLE IF NOT EXISTS plate_vehicles (
    id SERIAL PRIMARY KEY,
    plate VARCHAR(20) UNIQUE NOT NULL,
    make VARCHAR(100),
    model VARCHAR(100),
    year INTEGER,
    vin VARCHAR(17),
    customer_id INTEGER REFERENCES customers(id),
    created_at TIMESTAMPTZ DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_plate_vehicles_plate ON plate_vehicles(plate);
CREATE INDEX IF NOT EXISTS idx_plate_vehicles_customer ON plate_vehicles(customer_id);
