-- Sepet terk hatırlatma e-postası (cron) — shop_customers bayrağı. idempotent

SET @db := DATABASE();

SET @sql := (
  SELECT IF(
    EXISTS(
      SELECT 1 FROM information_schema.COLUMNS
      WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'shop_customers' AND COLUMN_NAME = 'cart_abandon_reminder_sent_at'
    ),
    'SELECT 1',
    'ALTER TABLE shop_customers ADD COLUMN cart_abandon_reminder_sent_at DATETIME NULL DEFAULT NULL AFTER updated_at'
  )
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
