<?php
declare(strict_types=1);

return [
    'up' => "
CREATE TABLE IF NOT EXISTS api_tokens (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    employee_id INT UNSIGNED NOT NULL,
    token VARCHAR(64) NOT NULL,
    name VARCHAR(100) NOT NULL DEFAULT 'default',
    abilities JSON NULL,
    last_used_at DATETIME NULL,
    expires_at DATETIME NULL,
    is_revoked TINYINT(1) NOT NULL DEFAULT 0,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE KEY uk_token (token),
    KEY idx_employee (employee_id),
    KEY idx_expires (expires_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS api_tokens",
];
