<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `employees` (
            `id`                    BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `username`              VARCHAR(50) NOT NULL,
            `password_hash`         VARCHAR(255) NOT NULL,
            `full_name_ar`          VARCHAR(200) NOT NULL,
            `full_name_en`          VARCHAR(200) NULL,
            `email`                 VARCHAR(255) NULL,
            `phone`                 VARCHAR(20) NULL,
            `branch_id`             BIGINT UNSIGNED NULL,
            `is_active`             TINYINT(1) NOT NULL DEFAULT 1,
            `force_password_change` TINYINT(1) NOT NULL DEFAULT 0,
            `password_changed_at`   TIMESTAMP NULL DEFAULT NULL,
            `last_login_at`         TIMESTAMP NULL DEFAULT NULL,
            `last_login_ip`         VARCHAR(45) NULL,
            `failed_login_count`    INT UNSIGNED NOT NULL DEFAULT 0,
            `locked_until`          TIMESTAMP NULL DEFAULT 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,
            `is_archived`           TINYINT(1) NOT NULL DEFAULT 0,
            `archived_at`           TIMESTAMP NULL DEFAULT NULL,
            `archived_by`           BIGINT UNSIGNED NULL,
            UNIQUE KEY `uq_employees_username` (`username`),
            INDEX `idx_employees_branch` (`branch_id`),
            INDEX `idx_employees_active` (`is_active`),
            INDEX `idx_employees_archived` (`is_archived`),
            CONSTRAINT `fk_employees_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 `employees`",
];