-- Salary Register Periods Table
-- Tracks created salary periods (similar to attendance_periods)

CREATE TABLE IF NOT EXISTS salary_periods (
    period_id INT AUTO_INCREMENT PRIMARY KEY,
    site_id INT NOT NULL,
    salary_month VARCHAR(10) NOT NULL COMMENT 'Format: Jan-25, Feb-25, etc.',
    period_display VARCHAR(50) NOT NULL COMMENT 'Format: January 2025, February 2025',
    employee_count INT DEFAULT 0,
    is_finalized TINYINT(1) DEFAULT 0,
    created_by INT DEFAULT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    finalized_at TIMESTAMP NULL DEFAULT NULL,
    
    UNIQUE KEY unique_site_period (site_id, salary_month),
    KEY idx_site_month (site_id, salary_month),
    KEY idx_created_at (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
