<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `active_sessions` (
            `id`               BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `employee_id`      BIGINT UNSIGNED NOT NULL,
            `session_id`       VARCHAR(128) NOT NULL,
            `ip_address`       VARCHAR(45) NOT NULL,
            `user_agent`       VARCHAR(500) NULL,
            `logged_in_at`     TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `last_activity_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `is_active`        TINYINT(1) NOT NULL DEFAULT 1,
            INDEX `idx_active_sessions_emp` (`employee_id`),
            INDEX `idx_active_sessions_session` (`session_id`),
            INDEX `idx_active_sessions_active` (`is_active`),
            CONSTRAINT `fk_active_sessions_emp` FOREIGN KEY (`employee_id`) REFERENCES `employees`(`id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `active_sessions`",
];