<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `purchase_requisition_items` (
            `id`                    BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `requisition_id`        BIGINT UNSIGNED NOT NULL,
            `item_id`               BIGINT UNSIGNED NULL COMMENT 'FK inventory_items.id — NULL for free-text items',
            `description_ar`        VARCHAR(300) NULL,
            `description_en`        VARCHAR(300) NULL,
            `quantity`              DECIMAL(15,3) NOT NULL,
            `unit_of_measure`       VARCHAR(50) NULL,
            `estimated_unit_cost`   DECIMAL(18,2) NULL,
            `estimated_line_total`  DECIMAL(18,2) NULL,
            `specifications`        TEXT NULL,
            `preferred_supplier_id` BIGINT UNSIGNED NULL COMMENT 'FK suppliers.id',
            INDEX `idx_pri_requisition` (`requisition_id`),
            INDEX `idx_pri_item` (`item_id`),
            CONSTRAINT `fk_pri_requisition` FOREIGN KEY (`requisition_id`) REFERENCES `purchase_requisitions`(`id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `purchase_requisition_items`",
];
