<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `item_categories` (
            `id`                BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `parent_id`         BIGINT UNSIGNED NULL,
            `code`              VARCHAR(30) NOT NULL,
            `name_ar`           VARCHAR(200) NOT NULL,
            `name_en`           VARCHAR(200) NULL,
            `description_ar`    TEXT NULL,
            `sort_order`        INT NOT NULL DEFAULT 0,
            `is_active`         TINYINT(1) NOT NULL DEFAULT 1,
            `is_archived`       TINYINT(1) NOT NULL DEFAULT 0,
            `archived_at`       TIMESTAMP NULL DEFAULT NULL,
            `archived_by`       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_item_categories_code` (`code`),
            INDEX `idx_item_categories_parent` (`parent_id`),
            INDEX `idx_item_categories_active` (`is_active`),
            CONSTRAINT `fk_item_categories_parent` FOREIGN KEY (`parent_id`) REFERENCES `item_categories` (`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `item_categories`",
];
