-- Optional ID document photo captured at rental contract (path under public/)
-- Idempotent: safe if column already exists (re-run migrations)

SET @dbname = DATABASE();
SET @preparedStatement = (SELECT IF(
  (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
   WHERE TABLE_SCHEMA = @dbname AND TABLE_NAME = 'rentals' AND COLUMN_NAME = 'id_document_image') > 0,
  'SELECT 1',
  'ALTER TABLE rentals ADD COLUMN id_document_image VARCHAR(255) NULL DEFAULT NULL COMMENT ''ID document photo path'' AFTER signature_image'
));
PREPARE stmt FROM @preparedStatement;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
