-- v1.2.0 发帖和回复时间间隔 数据库升级脚本
-- 目标数据库：LiveForumDB（业务库）
-- 说明: 创建 T_PostReplyIntervals 表，按认证等级配置发帖和回复的最小时间间隔
-- =============================================

-- 1. 创建 T_PostReplyIntervals 时间间隔配置表
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('T_PostReplyIntervals') AND type = 'U')
BEGIN
    CREATE TABLE T_PostReplyIntervals (
        Id INT IDENTITY(1,1) PRIMARY KEY,
        CertificationTypeId INT NOT NULL,
        PostInterval INT NOT NULL DEFAULT 0,
        ReplyInterval INT NOT NULL DEFAULT 0,
        CreatedAt DATETIME2 NOT NULL DEFAULT GETDATE(),
        UpdatedAt DATETIME2 NOT NULL DEFAULT GETDATE(),
        CONSTRAINT UQ_PostReplyIntervals_CertTypeId UNIQUE (CertificationTypeId),
        CONSTRAINT FK_PostReplyIntervals_CertType FOREIGN KEY (CertificationTypeId) REFERENCES T_CertificationTypes(Id)
    );
    PRINT '✓ T_PostReplyIntervals 表创建成功'
END
ELSE
BEGIN
    PRINT '⚠ T_PostReplyIntervals 表已存在，跳过创建'
END

PRINT 'v1.2.0 发帖和回复时间间隔升级脚本执行完成';
