-- Add agent_id column to payout_requests table
-- This allows tracking which agent made the payout request when used by agents

ALTER TABLE `payout_requests` ADD COLUMN `agent_id` INT(11) DEFAULT NULL COMMENT 'Agent ID if payout is from an agent' AFTER `landlord_id`;

-- Add foreign key constraint for agent_id (references users table)
ALTER TABLE `payout_requests` ADD KEY `agent_id` (`agent_id`);

-- Update the existing constraint to use FOREIGN KEY
ALTER TABLE `payout_requests` ADD CONSTRAINT `fk_payout_requests_agent_id` FOREIGN KEY (`agent_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;
