-- 为 goods 表添加 imgurl_banner 字段
-- 用于商城详情页顶部 banner 图

USE honey_box;
GO

-- 添加 imgurl_banner 字段
IF NOT EXISTS (
    SELECT * FROM sys.columns 
    WHERE object_id = OBJECT_ID(N'dbo.goods') 
    AND name = 'imgurl_banner'
)
BEGIN
    ALTER TABLE dbo.goods 
    ADD imgurl_banner NVARCHAR(500) NULL;
    
    PRINT 'Column imgurl_banner added successfully.';
END
ELSE
BEGIN
    PRINT 'Column imgurl_banner already exists.';
END
GO

-- 可选：将现有的 imgurl 复制到 imgurl_banner 作为初始值
-- UPDATE dbo.goods SET imgurl_banner = imgurl WHERE imgurl_banner IS NULL AND imgurl IS NOT NULL;
-- GO

PRINT 'Migration completed.';
GO
