<?php
declare(strict_types=1);

return [
    'up' => "
ALTER TABLE `daily_cash_movements` ADD COLUMN `movement_type` VARCHAR(50) NULL AFTER `movement_date`;
ALTER TABLE `daily_cash_movements` ADD COLUMN `direction` ENUM('in','out') NULL AFTER `movement_type`;
ALTER TABLE `daily_cash_movements` ADD COLUMN `amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00 AFTER `direction`;
ALTER TABLE `daily_cash_movements` ADD COLUMN `description` VARCHAR(500) NULL AFTER `amount`;
ALTER TABLE `daily_cash_movements` ADD COLUMN `reference_type` VARCHAR(100) NULL AFTER `description`;
ALTER TABLE `daily_cash_movements` ADD COLUMN `reference_id` INT UNSIGNED NULL AFTER `reference_type`;
ALTER TABLE `daily_cash_movements` DROP INDEX IF EXISTS `uk_date_bank`;
ALTER TABLE `daily_cash_movements` DROP INDEX IF EXISTS `uk_date_safe`;
ALTER TABLE `daily_cash_movements` ADD INDEX `idx_movement_date` (`movement_date`);
ALTER TABLE `daily_cash_movements` ADD INDEX `idx_movement_type` (`movement_type`);
ALTER TABLE `daily_cash_movements` ADD INDEX `idx_direction` (`direction`)",

    'down' => "
ALTER TABLE `daily_cash_movements` DROP INDEX IF EXISTS `idx_direction`;
ALTER TABLE `daily_cash_movements` DROP INDEX IF EXISTS `idx_movement_type`;
ALTER TABLE `daily_cash_movements` DROP INDEX IF EXISTS `idx_movement_date`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `reference_id`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `reference_type`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `description`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `amount`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `direction`;
ALTER TABLE `daily_cash_movements` DROP COLUMN IF EXISTS `movement_type`;
ALTER TABLE `daily_cash_movements` ADD UNIQUE KEY `uk_date_bank` (`movement_date`, `bank_account_id`);
ALTER TABLE `daily_cash_movements` ADD UNIQUE KEY `uk_date_safe` (`movement_date`, `safe_id`)",
];
