<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `package_items` (
            `id`          BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `package_id`  BIGINT UNSIGNED NOT NULL,
            `item_id`     BIGINT UNSIGNED NOT NULL,
            `quantity`    DECIMAL(15,3) NOT NULL DEFAULT 1.000,
            `sort_order`  INT NOT NULL DEFAULT 0,
            INDEX `idx_package_items_package` (`package_id`),
            INDEX `idx_package_items_item` (`item_id`),
            UNIQUE KEY `uq_package_items_package_item` (`package_id`, `item_id`),
            CONSTRAINT `fk_package_items_package` FOREIGN KEY (`package_id`) REFERENCES `packages`(`id`) ON DELETE CASCADE,
            CONSTRAINT `fk_package_items_item` FOREIGN KEY (`item_id`) REFERENCES `inventory_items`(`id`) ON DELETE RESTRICT
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `package_items`",
];
