<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `roles` (
            `id`              BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `role_code`       VARCHAR(50) NOT NULL,
            `name_ar`         VARCHAR(200) NOT NULL,
            `name_en`         VARCHAR(200) NULL,
            `description_ar`  VARCHAR(500) NULL,
            `description_en`  VARCHAR(500) NULL,
            `is_system`       TINYINT(1) NOT NULL DEFAULT 0,
            `is_active`       TINYINT(1) NOT NULL DEFAULT 1,
            `parent_role_id`  BIGINT UNSIGNED NULL,
            `created_at`      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `updated_at`      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            `created_by`      BIGINT UNSIGNED NULL,
            `updated_by`      BIGINT UNSIGNED NULL,
            UNIQUE KEY `uq_roles_code` (`role_code`),
            INDEX `idx_roles_parent` (`parent_role_id`),
            CONSTRAINT `fk_roles_parent` FOREIGN KEY (`parent_role_id`) REFERENCES `roles`(`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `roles`",
];