<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `audit_trail` (
            `id`                  BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `employee_id`         BIGINT UNSIGNED NULL,
            `employee_name`       VARCHAR(200) NULL,
            `action`              VARCHAR(50) NOT NULL,
            `entity_type`         VARCHAR(100) NULL,
            `entity_id`           BIGINT UNSIGNED NULL,
            `entity_label`        VARCHAR(255) NULL,
            `before_data_json`    JSON NULL,
            `after_data_json`     JSON NULL,
            `changed_fields_json` JSON NULL,
            `ip_address`          VARCHAR(45) NULL,
            `user_agent`          VARCHAR(500) NULL,
            `session_id`          VARCHAR(128) NULL,
            `route`               VARCHAR(255) NULL,
            `notes`               TEXT NULL,
            `created_at`          TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            INDEX `idx_audit_entity` (`entity_type`, `entity_id`),
            INDEX `idx_audit_employee` (`employee_id`),
            INDEX `idx_audit_date` (`created_at`),
            INDEX `idx_audit_action` (`action`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `audit_trail`",
];