-- Ekspertiz başına görev (paket içeriği) bazında personel ataması
CREATE TABLE IF NOT EXISTS `ekspertiz_personel` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `ekspertiz_id` int(11) unsigned NOT NULL,
  `gorev` varchar(50) NOT NULL COMMENT 'kaporta_boya, motor_performans, mekanik_test, sanziman_yol_testi, airbag_test, elektronik_test, ic_dis_aksam',
  `user_id` int(11) unsigned NULL COMMENT 'Atanan personel (users.id)',
  `diger_adi` varchar(100) NULL COMMENT 'Diğer seçilirse isim',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_ekspertiz_gorev` (`ekspertiz_id`,`gorev`),
  KEY `idx_ekspertiz_personel_ekspertiz` (`ekspertiz_id`),
  CONSTRAINT `fk_ekspertiz_personel_ekspertiz` FOREIGN KEY (`ekspertiz_id`) REFERENCES `ekspertizler` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_ekspertiz_personel_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
