const mongoose = require('mongoose');

const vehicleSchema = new mongoose.Schema({
  vehicle_number: { type: String, required: true, unique: true },
  model: { type: String, required: true },
  make: { type: String, required: true },
  year: { type: Number, required: true },
  registration_number: { type: String, required: true, unique: true },
  insurance_expiry: { type: Date, required: true },
  status: { type: String, enum: ['available','on_trip','maintenance','inactive'], default: 'available' },
  capacity: { type: Number, required: true },
  fuel_type: { type: String, enum: ['petrol','diesel','electric','hybrid'], default: 'diesel' },
  purchase_date: { type: Date, required: true },
  mileage: { type: Number, default: 0 },
  color: String,
  vin: { type: String, unique: true, sparse: true },
}, { timestamps: true });

module.exports = mongoose.model('Vehicle', vehicleSchema);
