-- DryClean360 — Server database update
-- Date: 2026-07-07
-- Apply to database: dryclean360_db
--
-- Usage (MySQL):
--   mysql -u root -p dryclean360_db < scripts/server_update_20260707.sql
--
-- Safe to run more than once (checks column before adding).

USE `dryclean360_db`;

SET @col_exists := (
    SELECT COUNT(*)
    FROM information_schema.COLUMNS
    WHERE TABLE_SCHEMA = DATABASE()
      AND TABLE_NAME = 'shop_settings_shopprofile'
      AND COLUMN_NAME = 'client_logo'
);

SET @sql := IF(
    @col_exists = 0,
    'ALTER TABLE `shop_settings_shopprofile`
     ADD COLUMN `client_logo` VARCHAR(255) NOT NULL DEFAULT '''' AFTER `invoice_terms`',
    'SELECT ''client_logo column already exists'' AS message'
);

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

-- Verify
SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_DEFAULT
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
  AND TABLE_NAME = 'shop_settings_shopprofile'
  AND COLUMN_NAME = 'client_logo';
