-- Add GitHub backup tracking columns to backup_history table
-- These columns track GitHub upload status and local file management

-- Add column to track if backup was uploaded to GitHub
ALTER TABLE backup_history 
ADD COLUMN IF NOT EXISTS github_uploaded BOOLEAN DEFAULT FALSE;

-- Add column to track if local file was deleted after GitHub upload
ALTER TABLE backup_history 
ADD COLUMN IF NOT EXISTS local_deleted BOOLEAN DEFAULT FALSE;

-- Add column to store GitHub path/filename
ALTER TABLE backup_history 
ADD COLUMN IF NOT EXISTS github_path TEXT;

-- Add column to identify server backups vs database backups
ALTER TABLE backup_history 
ADD COLUMN IF NOT EXISTS is_server_backup BOOLEAN DEFAULT FALSE;

-- Create index for faster queries on GitHub status
CREATE INDEX IF NOT EXISTS idx_backup_history_github_status 
ON backup_history(github_uploaded, local_deleted);

-- Add comments for documentation
COMMENT ON COLUMN backup_history.github_uploaded IS 'Whether backup was uploaded to GitHub repository';
COMMENT ON COLUMN backup_history.local_deleted IS 'Whether local backup file was deleted after GitHub upload';
COMMENT ON COLUMN backup_history.github_path IS 'Path/filename of backup in GitHub repository';
COMMENT ON COLUMN backup_history.is_server_backup IS 'True for full server backups, False for database-only backups';