<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `role_permissions` (
            `id`              BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `role_id`         BIGINT UNSIGNED NOT NULL,
            `permission_key`  VARCHAR(100) NOT NULL,
            `granted_at`      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `granted_by`      BIGINT UNSIGNED NULL,
            UNIQUE KEY `uq_role_perm` (`role_id`, `permission_key`),
            INDEX `idx_role_permissions_key` (`permission_key`),
            CONSTRAINT `fk_role_permissions_role` FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `role_permissions`",
];