CREATE TABLE IF NOT EXISTS `helpdesk_handovers` (
    `id`              BIGINT UNSIGNED  NOT NULL AUTO_INCREMENT,
    `tenant_id`       INT UNSIGNED     NOT NULL,
    `debitor_no`      VARCHAR(30)      NOT NULL,
    `debitor_name`    VARCHAR(255)     NOT NULL DEFAULT '',
    `product_code`    VARCHAR(30)      NOT NULL,
    `status`          VARCHAR(20)      NOT NULL DEFAULT 'draft',
    `schema_snapshot` TEXT             NULL     DEFAULT NULL,
    `field_values`    TEXT             NULL     DEFAULT NULL,
    `created_by`      INT UNSIGNED     NOT NULL,
    `updated_by`      INT UNSIGNED     NULL     DEFAULT NULL,
    `created_at`      DATETIME         NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at`      DATETIME         NULL     DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    KEY `idx_hh_tenant`  (`tenant_id`),
    KEY `idx_hh_debitor` (`tenant_id`, `debitor_no`),
    KEY `idx_hh_product` (`tenant_id`, `product_code`),
    KEY `idx_hh_status`  (`tenant_id`, `status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
