-- cooper57_vehicles backup
-- Generated: 2026-09-06 23:42:57

SET FOREIGN_KEY_CHECKS=0;

-- --------------------------------------------------
-- Table: vehicles
-- --------------------------------------------------
DROP TABLE IF EXISTS `vehicles`;
CREATE TABLE `vehicles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `year` smallint(6) DEFAULT NULL,
  `make` varchar(100) DEFAULT NULL,
  `model` varchar(100) DEFAULT NULL,
  `current_odometer` int(11) 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', 'Chevrolet Trailblazer', '2024', 'Chevrolet', 'Trailblazer', '45230', '2026-08-15 17:34:19'),
('2', '2025 Subaru Crosstrek Premium', '2025', 'Subaru', 'crosstrek', '4497', '2026-08-15 17:34:19');

-- --------------------------------------------------
-- Table: fillups
-- --------------------------------------------------
DROP TABLE IF EXISTS `fillups`;
CREATE TABLE `fillups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `vehicle_id` int(11) NOT NULL,
  `fill_date` date NOT NULL,
  `odometer` int(11) 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=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `fillups` (`id`, `vehicle_id`, `fill_date`, `odometer`, `gallons`, `cost`, `created_at`) VALUES
('1', '2', '2025-07-25', '222', '7.870', '29.90', '2026-08-15 17:45:21'),
('2', '2', '2025-08-18', '537', '10.870', '42.40', '2026-08-15 17:47:14'),
('3', '2', '2025-09-13', '839', '10.740', '42.95', '2026-08-15 17:49:10'),
('4', '2', '2025-10-13', '1191', '12.960', '53.50', '2026-08-15 17:50:25'),
('5', '2', '2025-11-06', '1470', '10.860', '42.05', '2026-08-15 17:51:41'),
('6', '2', '2025-12-02', '1725', '10.400', '39.20', '2026-08-15 17:52:49'),
('7', '2', '2025-12-24', '1905', '9.360', '33.25', '2026-08-15 17:53:56'),
('8', '2', '2026-01-22', '2174', '11.910', '43.00', '2026-08-15 17:58:47'),
('9', '2', '2026-02-18', '2476', '12.150', '48.75', '2026-08-15 17:59:52'),
('10', '2', '2026-03-18', '2724', '10.870', '51.75', '2026-08-15 18:14:26'),
('11', '2', '2026-04-10', '2948', '9.510', '47.20', '2026-08-15 18:16:17'),
('12', '2', '2026-05-05', '3276', '11.750', '67.00', '2026-08-15 20:24:40'),
('13', '2', '2026-06-05', '3586', '11.900', '56.65', '2026-08-15 20:36:22'),
('14', '2', '2026-07-01', '3874', '10.300', '54.00', '2026-08-15 20:38:01'),
('15', '2', '2026-07-28', '4168', '10.960', '57.45', '2026-08-15 20:39:35'),
('16', '2', '2026-08-26', '4497', '11.530', '58.80', '2026-08-26 15:33:04');

-- --------------------------------------------------
-- Table: maintenance_items
-- --------------------------------------------------
DROP TABLE IF EXISTS `maintenance_items`;
CREATE TABLE `maintenance_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `vehicle_id` int(11) NOT NULL,
  `name` varchar(150) NOT NULL,
  `interval_miles` int(11) DEFAULT NULL,
  `interval_months` int(11) DEFAULT NULL,
  `last_odometer` int(11) 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;

INSERT INTO `maintenance_items` (`id`, `vehicle_id`, `name`, `interval_miles`, `interval_months`, `last_odometer`, `last_date`, `created_at`) VALUES
('1', '2', 'oil change and filter', '6000', '6', '4103', '2026-07-21', '2026-08-17 12:50:21');

SET FOREIGN_KEY_CHECKS=1;
