-- cooper57_vehicles backup
-- Generated: 2026-08-15 21:15:36

SET FOREIGN_KEY_CHECKS=0;

-- --------------------------------------------------
-- Table: vehicles
-- --------------------------------------------------
DROP TABLE IF EXISTS `vehicles`;
CREATE TABLE `vehicles` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `year` smallint DEFAULT NULL,
  `make` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `model` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `current_odometer` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `vehicles` (`id`, `name`, `year`, `make`, `model`, `current_odometer`, `created_at`) VALUES
('1', 'The Truck', '2019', 'Toyota', 'Tacoma', '45230', '2026-08-15 21:34:19');

-- --------------------------------------------------
-- Table: fillups
-- --------------------------------------------------
DROP TABLE IF EXISTS `fillups`;
CREATE TABLE `fillups` (
  `id` int NOT NULL AUTO_INCREMENT,
  `vehicle_id` int NOT NULL,
  `fill_date` date NOT NULL,
  `odometer` int NOT NULL,
  `gallons` decimal(6,3) NOT NULL,
  `cost` decimal(8,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_vehicle_odo` (`vehicle_id`,`odometer`),
  CONSTRAINT `fillups_ibfk_1` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------
-- Table: maintenance_items
-- --------------------------------------------------
DROP TABLE IF EXISTS `maintenance_items`;
CREATE TABLE `maintenance_items` (
  `id` int NOT NULL AUTO_INCREMENT,
  `vehicle_id` int NOT NULL,
  `name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `interval_miles` int DEFAULT NULL,
  `interval_months` int DEFAULT NULL,
  `last_odometer` int NOT NULL DEFAULT '0',
  `last_date` date NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `vehicle_id` (`vehicle_id`),
  CONSTRAINT `maintenance_items_ibfk_1` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

SET FOREIGN_KEY_CHECKS=1;
