<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `rtv_items` (
            `id`              BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `rtv_id`          BIGINT UNSIGNED NOT NULL,
            `item_id`         BIGINT UNSIGNED NOT NULL COMMENT 'FK inventory_items.id',
            `grn_item_id`     BIGINT UNSIGNED NULL COMMENT 'FK grn_items.id',
            `quantity`         DECIMAL(15,3) NOT NULL,
            `unit_cost`       DECIMAL(18,2) NOT NULL,
            `line_total`      DECIMAL(18,2) NOT NULL,
            `batch_number`    VARCHAR(100) NULL,
            `reason`          TEXT NULL,
            INDEX `idx_rtvi_rtv` (`rtv_id`),
            INDEX `idx_rtvi_item` (`item_id`),
            INDEX `idx_rtvi_grn_item` (`grn_item_id`),
            CONSTRAINT `fk_rtvi_rtv` FOREIGN KEY (`rtv_id`) REFERENCES `return_to_vendor`(`id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `rtv_items`",
];
