-- ============================================
-- 7. BRANCH MODULE
-- ============================================

DROP TABLE IF EXISTS `branches`;

CREATE TABLE `branches` (
    `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `name` VARCHAR(100) NOT NULL,
    `address` TEXT,
    `phone` VARCHAR(20),
    `pic` VARCHAR(100) COMMENT 'Person In Charge',
    `is_active` BOOLEAN DEFAULT TRUE,
    `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    INDEX idx_active (`is_active`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

-- Insert default Head Office branch
INSERT INTO
    `branches` (
        `name`,
        `address`,
        `phone`,
        `pic`,
        `is_active`
    )
VALUES (
        'Head Office',
        'Main Location',
        '08123456789',
        'Manager',
        TRUE
    );