CREATE TABLE `tender_invitations` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `tender_request_id` BIGINT UNSIGNED NOT NULL,
    `prestataire_id` BIGINT UNSIGNED NOT NULL,
    `type` ENUM('auto_match', 'manual_invite', 'category_match') NOT NULL,
    `match_score` INT NOT NULL DEFAULT 0,
    `match_reasons` JSON NULL,
    `is_read` TINYINT(1) NOT NULL DEFAULT 0,
    `is_interested` TINYINT(1) NULL,
    `read_at` DATETIME NULL,
    `responded_at` DATETIME NULL,
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    UNIQUE KEY `tender_invitations_unique` (`tender_request_id`, `prestataire_id`),
    CONSTRAINT `tender_invitations_tender_request_id_foreign` FOREIGN KEY (`tender_request_id`) REFERENCES `tender_requests` (`id`) ON DELETE CASCADE,
    CONSTRAINT `tender_invitations_prestataire_id_foreign` FOREIGN KEY (`prestataire_id`) REFERENCES `prestataires` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
