-- ============================================
-- إنشاء جدول المركبات
-- AUTO TESTER - Vehicles Table
-- ============================================

CREATE TABLE IF NOT EXISTS vehicles (
    id INT PRIMARY KEY AUTO_INCREMENT,
    client_id INT NOT NULL,
    
    -- معلومات المركبة
    brand VARCHAR(50) NOT NULL,
    model VARCHAR(50) NOT NULL,
    year INT,
    color VARCHAR(30),
    
    -- الأرقام
    plate_number VARCHAR(20) UNIQUE NOT NULL,
    vin VARCHAR(50) UNIQUE NOT NULL,
    engine_number VARCHAR(50),
    
    -- المواصفات
    mileage INT,
    fuel_type ENUM('petrol95', 'petrol91', 'diesel', 'hybrid', 'electric') DEFAULT 'petrol95',
    engine_cc INT,
    
    -- الصور
    front_image TEXT,
    left_image TEXT,
    rear_image TEXT,
    right_image TEXT,
    interior_front TEXT,
    interior_rear TEXT,
    
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    
    FOREIGN KEY (client_id) REFERENCES users(id),
    
    INDEX idx_client (client_id),
    INDEX idx_plate (plate_number),
    INDEX_idx_vin (vin)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;