<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `stock_transfer_items` (
            `id`          BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `transfer_id` BIGINT UNSIGNED NOT NULL,
            `item_id`     BIGINT UNSIGNED NOT NULL,
            `quantity`    DECIMAL(15,3) NOT NULL,
            `batch_id`    BIGINT UNSIGNED NULL,
            `notes`       TEXT NULL,
            INDEX `idx_sti_transfer` (`transfer_id`),
            INDEX `idx_sti_item` (`item_id`),
            CONSTRAINT `fk_sti_transfer` FOREIGN KEY (`transfer_id`) REFERENCES `stock_transfers`(`id`) ON DELETE CASCADE,
            CONSTRAINT `fk_sti_item` FOREIGN KEY (`item_id`) REFERENCES `inventory_items`(`id`) ON DELETE RESTRICT,
            CONSTRAINT `fk_sti_batch` FOREIGN KEY (`batch_id`) REFERENCES `item_batches`(`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `stock_transfer_items`",
];
