-- Step 38: Add customer default name
-- Feature: Customer account profile preferences
-- Date: 2026-04-27
--
-- Adds a separate customer name for delivery, pickup, and booking workflows.
-- `displayName` remains the optional nickname used for public/account UI.

SET @column_exists := (
  SELECT COUNT(*)
  FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'customerUsers'
    AND COLUMN_NAME = 'defaultName'
);

SET @sql := IF(
  @column_exists = 0,
  'ALTER TABLE `customerUsers` ADD COLUMN `defaultName` varchar(120) DEFAULT NULL AFTER `displayName`',
  'SELECT ''customerUsers.defaultName already exists'' AS message'
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
