<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `vendor_invoice_items` (
            `id`                BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `invoice_id`        BIGINT UNSIGNED NOT NULL,
            `po_item_id`        BIGINT UNSIGNED NULL COMMENT 'FK purchase_order_items.id',
            `item_id`           BIGINT UNSIGNED NULL COMMENT 'FK inventory_items.id',
            `description`       VARCHAR(300) NULL,
            `quantity`          DECIMAL(15,3) NOT NULL,
            `unit_cost`         DECIMAL(18,2) NOT NULL,
            `tax_rate`          DECIMAL(5,2) NOT NULL DEFAULT 0.00,
            `tax_amount`        DECIMAL(18,2) NOT NULL DEFAULT 0.00,
            `discount_amount`   DECIMAL(18,2) NOT NULL DEFAULT 0.00,
            `line_total`        DECIMAL(18,2) NOT NULL,
            INDEX `idx_vii_invoice` (`invoice_id`),
            INDEX `idx_vii_item` (`item_id`),
            CONSTRAINT `fk_vii_invoice` FOREIGN KEY (`invoice_id`) REFERENCES `vendor_invoices`(`id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `vendor_invoice_items`",
];
