-- School branches + students.branch_id
CREATE TABLE IF NOT EXISTS school_branches (
    id INT AUTO_INCREMENT PRIMARY KEY,
    branch_name VARCHAR(100) NOT NULL,
    branch_code VARCHAR(20) NOT NULL,
    address TEXT NULL,
    status ENUM('active', 'inactive') DEFAULT 'active',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE KEY unique_branch_code (branch_code)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE students ADD COLUMN IF NOT EXISTS branch_id INT NULL DEFAULT NULL AFTER class_id;

INSERT IGNORE INTO school_branches (branch_name, branch_code) VALUES
('মূল শাখা', 'MAIN'),
('উত্তর শাখা', 'NORTH'),
('দক্ষিণ শাখা', 'SOUTH');
