-- Migration 34: defect_types
-- Warranty defect classification lookup table.

CREATE TABLE IF NOT EXISTS `defect_types` (
  `id`          int(10) unsigned NOT NULL AUTO_INCREMENT,
  `code`        varchar(20)  NOT NULL,
  `title`       varchar(100) NOT NULL COMMENT 'Persian title',
  `description` text         DEFAULT NULL,
  `is_active`   tinyint(1)   NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Seed one active defect type so registerWarranty() tests can reference defect_type_id
INSERT IGNORE INTO `defect_types` (`id`, `code`, `title`, `is_active`)
VALUES (1, 'GENERAL', 'نقص عمومی', 1);
