<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `asset_register` (
            `id`                         BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `item_id`                    BIGINT UNSIGNED NOT NULL,
            `warehouse_id`               BIGINT UNSIGNED NOT NULL,
            `asset_tag`                  VARCHAR(50) NOT NULL,
            `serial_number`              VARCHAR(100) NULL,
            `purchase_date`              DATE NOT NULL,
            `purchase_cost`              DECIMAL(15,2) NOT NULL,
            `useful_life_months`         INT UNSIGNED NOT NULL DEFAULT 60,
            `salvage_value`              DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `depreciation_method`        VARCHAR(30) NOT NULL DEFAULT 'straight_line' COMMENT 'straight_line, declining_balance',
            `declining_rate`             DECIMAL(5,2) NULL,
            `accumulated_depreciation`   DECIMAL(15,2) NOT NULL DEFAULT 0.00,
            `book_value`                 DECIMAL(15,2) NOT NULL,
            `status`                     VARCHAR(20) NOT NULL DEFAULT 'active' COMMENT 'active, disposed, transferred, under_maintenance',
            `disposed_at`                DATE NULL,
            `disposal_value`             DECIMAL(15,2) NULL,
            `disposal_reason`            TEXT NULL,
            `condition_notes`            TEXT NULL,
            `last_depreciation_date`     DATE NULL,
            `branch_id`                  BIGINT UNSIGNED NULL,
            `is_archived`                TINYINT(1) NOT NULL DEFAULT 0,
            `archived_at`                TIMESTAMP NULL DEFAULT NULL,
            `archived_by`                BIGINT UNSIGNED NULL,
            `created_at`                 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `updated_at`                 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            `created_by`                 BIGINT UNSIGNED NULL,
            `updated_by`                 BIGINT UNSIGNED NULL,
            UNIQUE KEY `uq_asset_register_asset_tag` (`asset_tag`),
            INDEX `idx_asset_register_item` (`item_id`),
            INDEX `idx_asset_register_warehouse` (`warehouse_id`),
            INDEX `idx_asset_register_status` (`status`),
            INDEX `idx_asset_register_purchase_date` (`purchase_date`),
            INDEX `idx_asset_register_method` (`depreciation_method`),
            CONSTRAINT `fk_asset_register_item` FOREIGN KEY (`item_id`) REFERENCES `inventory_items` (`id`) ON DELETE RESTRICT,
            CONSTRAINT `fk_asset_register_warehouse` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouses` (`id`) ON DELETE RESTRICT
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `asset_register`",
];
