CREATE TABLE IF NOT EXISTS `helpdesk_handover_revisions` (
    `id`             BIGINT UNSIGNED  NOT NULL AUTO_INCREMENT,
    `tenant_id`      INT UNSIGNED     NOT NULL,
    `handover_id`    BIGINT UNSIGNED  NOT NULL,
    `revision`       INT UNSIGNED     NOT NULL,
    `field_values`   TEXT             NULL     DEFAULT NULL,
    `status`         VARCHAR(20)      NOT NULL,
    `schema_version` INT UNSIGNED     NOT NULL DEFAULT 1,
    `change_type`    VARCHAR(20)      NOT NULL DEFAULT 'fields',
    `changed_by`     INT UNSIGNED     NOT NULL,
    `created_at`     DATETIME         NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uq_hr_handover_revision` (`handover_id`, `revision`),
    KEY `idx_hr_tenant_handover` (`tenant_id`, `handover_id`),
    KEY `idx_hr_handover_created` (`handover_id`, `created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
