zhibo/create_gift_table.sql
2026-01-03 19:22:42 +08:00

53 lines
2.3 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ========================================
-- 创建礼物表
-- ========================================
-- 检查表是否存在
SELECT TABLE_NAME
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'zhibo'
AND TABLE_NAME = 'eb_gift';
-- 创建礼物表
CREATE TABLE IF NOT EXISTS `eb_gift` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '礼物ID',
`name` varchar(100) NOT NULL COMMENT '礼物名称',
`icon` varchar(500) DEFAULT NULL COMMENT '礼物图标URL',
`price` int NOT NULL DEFAULT '0' COMMENT '价格(钻石)',
`sort` int NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态1-启用0-禁用',
`description` varchar(500) DEFAULT NULL COMMENT '礼物描述',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`is_delete` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除0-否1-是',
PRIMARY KEY (`id`),
KEY `idx_status` (`status`),
KEY `idx_sort` (`sort`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='礼物表';
-- 插入一些示例礼物数据
INSERT INTO `eb_gift` (`name`, `icon`, `price`, `sort`, `status`, `description`) VALUES
('玫瑰', 'https://example.com/gifts/rose.png', 1, 1, 1, '送你一朵玫瑰'),
('巧克力', 'https://example.com/gifts/chocolate.png', 5, 2, 1, '甜蜜的巧克力'),
('棒棒糖', 'https://example.com/gifts/lollipop.png', 10, 3, 1, '甜甜的棒棒糖'),
('冰淇淋', 'https://example.com/gifts/icecream.png', 20, 4, 1, '清凉的冰淇淋'),
('蛋糕', 'https://example.com/gifts/cake.png', 50, 5, 1, '美味的蛋糕'),
('香水', 'https://example.com/gifts/perfume.png', 100, 6, 1, '迷人的香水'),
('口红', 'https://example.com/gifts/lipstick.png', 200, 7, 1, '魅力口红'),
('钻戒', 'https://example.com/gifts/ring.png', 500, 8, 1, '闪耀的钻戒'),
('跑车', 'https://example.com/gifts/car.png', 1000, 9, 1, '豪华跑车'),
('城堡', 'https://example.com/gifts/castle.png', 5000, 10, 1, '梦幻城堡')
ON DUPLICATE KEY UPDATE name=name;
-- 验证数据
SELECT
'=== 礼物列表 ===' as section,
id,
name,
price,
sort,
CASE WHEN status = 1 THEN '启用' ELSE '禁用' END as status,
create_time
FROM eb_gift
ORDER BY sort;