-- Create categories table
CREATE TABLE IF NOT EXISTS `categories` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(100) NOT NULL UNIQUE,
  `description` TEXT NULL,
  `isActive` TINYINT(1) NOT NULL DEFAULT 1,
  `createdAt` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedAt` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Insert default categories
INSERT INTO `categories` (`name`, `description`, `isActive`) VALUES
('headlights', 'Headlights and lighting components', 1),
('radiators', 'Radiators and cooling system parts', 1),
('windshields', 'Windshields and glass components', 1),
('bumpers', 'Bumpers and body panels', 1),
('engines', 'Engines and engine components', 1),
('transmissions', 'Transmissions and drivetrain parts', 1),
('other', 'Other spare parts', 1)
ON DUPLICATE KEY UPDATE `name`=`name`;

