杂务:同步主初始化SQL标签店铺唯一约束
This commit is contained in:
@@ -399,8 +399,8 @@ create table t_tag
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删',
|
||||
shop_id bigint null comment '店铺ID',
|
||||
constraint uk_tag_name
|
||||
unique (tag_name) comment '标签名称唯一索引'
|
||||
constraint uk_tag_shop_name
|
||||
unique (shop_id, tag_name) comment '店铺内标签名称唯一索引'
|
||||
)
|
||||
comment '系统标签信息表';
|
||||
|
||||
@@ -697,6 +697,25 @@ CALL sp_add_index_if_not_exists('t_order', 'idx_t_order_coupon_source_type', '(`
|
||||
CALL sp_add_column_if_not_exists('t_order_item', 'appointment_time', 'datetime NULL COMMENT ''预约开始时间''');
|
||||
CALL sp_add_index_if_not_exists('t_order_item', 'idx_t_order_item_artist_appointment_time', '(`artist_id`, `appointment_time`)');
|
||||
|
||||
SET @drop_old_tag_unique_sql = (
|
||||
SELECT IF(
|
||||
EXISTS(
|
||||
SELECT 1
|
||||
FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 't_tag'
|
||||
AND INDEX_NAME = 'uk_tag_name'
|
||||
),
|
||||
'ALTER TABLE `t_tag` DROP INDEX `uk_tag_name`',
|
||||
'SELECT 1'
|
||||
)
|
||||
);
|
||||
PREPARE stmt FROM @drop_old_tag_unique_sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
CALL sp_add_unique_index_if_not_exists('t_tag', 'uk_tag_shop_name', '(`shop_id`, `tag_name`)');
|
||||
|
||||
CALL sp_add_column_if_not_exists('t_coupon', 'coupon_scene', 'varchar(32) NOT NULL DEFAULT ''NORMAL'' COMMENT ''优惠券场景''');
|
||||
CALL sp_add_column_if_not_exists('t_coupon', 'required_vip_level', 'varchar(20) NULL COMMENT ''要求的VIP等级''');
|
||||
CALL sp_add_column_if_not_exists('t_coupon', 'auto_match', 'tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''是否自动匹配''');
|
||||
|
||||
Reference in New Issue
Block a user