HaniBlindBox/server/HoneyBox/scripts/create_goods_locks_table.sql
2026-01-22 02:12:08 +08:00

27 lines
921 B
Transact-SQL

-- 创建 goods_locks 表(锁箱功能)
-- 用于一番赏、全局赏、追踪赏的锁箱功能
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[goods_locks]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[goods_locks] (
[id] INT IDENTITY(1,1) NOT NULL,
[user_id] INT NOT NULL,
[goods_id_num] NVARCHAR(50) NOT NULL,
[end_time] BIGINT NOT NULL,
[update_time] BIGINT NOT NULL,
CONSTRAINT [PK_goods_locks] PRIMARY KEY CLUSTERED ([id] ASC)
);
-- 创建索引
CREATE INDEX [IX_goods_locks_goods_id_num] ON [dbo].[goods_locks] ([goods_id_num]);
CREATE INDEX [IX_goods_locks_user_id] ON [dbo].[goods_locks] ([user_id]);
CREATE INDEX [IX_goods_locks_end_time] ON [dbo].[goods_locks] ([end_time]);
PRINT 'Table goods_locks created successfully.';
END
ELSE
BEGIN
PRINT 'Table goods_locks already exists.';
END
GO