-- Add notes field to products/items for internal product remarks.
-- Safe to run multiple times on existing databases.

SET @db_name := DATABASE();

SET @sql := IF (
  EXISTS (
    SELECT 1 FROM information_schema.COLUMNS
    WHERE TABLE_SCHEMA = @db_name AND TABLE_NAME = 'items' AND COLUMN_NAME = 'notes'
  ),
  'SELECT 1',
  "ALTER TABLE items ADD COLUMN notes text DEFAULT NULL AFTER image_url"
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
