<?php
declare(strict_types=1);

return [
    'up' => "
CREATE TABLE IF NOT EXISTS inventory_opening_balances (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    warehouse_id INT UNSIGNED NOT NULL,
    item_id INT UNSIGNED NOT NULL,
    quantity DECIMAL(12,3) NOT NULL DEFAULT 0.000,
    unit_cost DECIMAL(15,2) NOT NULL DEFAULT 0.00,
    total_cost DECIMAL(15,2) NOT NULL DEFAULT 0.00,
    balance_date DATE NOT NULL,
    batch_reference VARCHAR(50) NULL,
    stock_movement_id INT UNSIGNED NULL,
    notes TEXT NULL,
    created_by INT UNSIGNED NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    KEY idx_warehouse (warehouse_id),
    KEY idx_item (item_id),
    KEY idx_date (balance_date),
    UNIQUE KEY uk_warehouse_item_date (warehouse_id, item_id, balance_date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS inventory_opening_balances",
];
