<?php
declare(strict_types=1);

return [
    'up' => "
ALTER TABLE asset_register ADD COLUMN custodian_employee_id INT UNSIGNED NULL AFTER condition_notes;
ALTER TABLE asset_register ADD COLUMN site_location VARCHAR(255) NULL AFTER custodian_employee_id;
ALTER TABLE asset_register ADD COLUMN custody_date DATE NULL AFTER site_location;

CREATE TABLE IF NOT EXISTS asset_custody_history (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    asset_id INT UNSIGNED NOT NULL,
    from_employee_id INT UNSIGNED NULL,
    to_employee_id INT UNSIGNED NULL,
    from_location VARCHAR(255) NULL,
    to_location VARCHAR(255) NULL,
    transfer_date DATE NOT NULL,
    reason VARCHAR(500) NULL,
    notes TEXT NULL,
    created_by INT UNSIGNED NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    KEY idx_asset (asset_id),
    KEY idx_from_emp (from_employee_id),
    KEY idx_to_emp (to_employee_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "
DROP TABLE IF EXISTS asset_custody_history;
ALTER TABLE asset_register DROP COLUMN custody_date;
ALTER TABLE asset_register DROP COLUMN site_location;
ALTER TABLE asset_register DROP COLUMN custodian_employee_id",
];
