<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `inventory_items` (
            `id`                    BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `category_id`           BIGINT UNSIGNED NULL,
            `sku`                   VARCHAR(50) NOT NULL,
            `barcode`               VARCHAR(100) NULL,
            `name_ar`               VARCHAR(300) NOT NULL,
            `name_en`               VARCHAR(300) NULL,
            `description_ar`        TEXT NULL,
            `unit_of_measure`       VARCHAR(30) NOT NULL DEFAULT 'piece' COMMENT 'piece, kg, liter, box, pack, meter, set',
            `tracking_type`         VARCHAR(20) NOT NULL DEFAULT 'standard' COMMENT 'standard, expiry, asset',
            `cost_price`            DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `sale_price_member`     DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `sale_price_nonmember`  DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `sale_price_player`     DECIMAL(15,2) NULL,
            `tax_rate`              DECIMAL(5,2) NOT NULL DEFAULT 0.00,
            `is_sellable`           TINYINT(1) NOT NULL DEFAULT 1,
            `is_active`             TINYINT(1) NOT NULL DEFAULT 1,
            `image_document_id`     BIGINT UNSIGNED NULL,
            `notes`                 TEXT NULL,
            `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_inventory_items_sku` (`sku`),
            INDEX `idx_inventory_items_category` (`category_id`),
            INDEX `idx_inventory_items_barcode` (`barcode`),
            INDEX `idx_inventory_items_tracking` (`tracking_type`),
            INDEX `idx_inventory_items_active` (`is_active`),
            INDEX `idx_inventory_items_sellable` (`is_sellable`),
            CONSTRAINT `fk_inventory_items_category` FOREIGN KEY (`category_id`) REFERENCES `item_categories` (`id`) ON DELETE SET NULL,
            CONSTRAINT `fk_inventory_items_image` FOREIGN KEY (`image_document_id`) REFERENCES `documents` (`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `inventory_items`",
];
