<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `discount_rules` (
            `id`                      BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `discount_code`           VARCHAR(50) NOT NULL,
            `name_ar`                 VARCHAR(200) NOT NULL,
            `name_en`                 VARCHAR(200) NULL,
            `discount_type`           VARCHAR(30) NOT NULL DEFAULT 'percentage',
            `value`                   DECIMAL(15,2) NOT NULL,
            `min_quantity`            INT UNSIGNED NULL,
            `max_quantity`            INT UNSIGNED NULL,
            `stackable`               TINYINT(1) NOT NULL DEFAULT 0,
            `max_discount_percentage` DECIMAL(5,2) NULL,
            `branch_id`               BIGINT UNSIGNED NULL,
            `effective_from`          DATE NOT NULL,
            `effective_to`            DATE NULL DEFAULT NULL,
            `is_active`               TINYINT(1) NOT NULL DEFAULT 1,
            `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,
            INDEX `idx_discount_rules_code` (`discount_code`),
            INDEX `idx_discount_rules_active` (`is_active`),
            CONSTRAINT `fk_discount_rules_branch` FOREIGN KEY (`branch_id`) REFERENCES `branches`(`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `discount_rules`",
];