-- Add contact_id to clients table for backward compatibility
ALTER TABLE `clients` ADD COLUMN IF NOT EXISTS `contact_id` bigint unsigned DEFAULT NULL AFTER `company`;
ALTER TABLE `clients` ADD KEY IF NOT EXISTS `contact_id` (`contact_id`);

-- Add contact_id to invoices table
ALTER TABLE `invoices` ADD COLUMN IF NOT EXISTS `contact_id` bigint unsigned DEFAULT NULL AFTER `client_id`;
ALTER TABLE `invoices` ADD KEY IF NOT EXISTS `contact_id` (`contact_id`);

-- Add contact_id to bookings table  
ALTER TABLE `bookings` ADD COLUMN IF NOT EXISTS `contact_id` bigint unsigned DEFAULT NULL AFTER `client_id`;
ALTER TABLE `bookings` ADD KEY IF NOT EXISTS `contact_id` (`contact_id`);
