整理双端初始化SQL脚本
This commit is contained in:
File diff suppressed because it is too large
Load Diff
+13
-1
@@ -1732,6 +1732,7 @@ ON DUPLICATE KEY UPDATE
|
||||
is_delete = 0,
|
||||
update_time = NOW();
|
||||
|
||||
|
||||
CALL sp_add_column_if_not_exists('t_order', 'customer_remark', 'varchar(500) NULL COMMENT ''用户询价预约备注''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'quote_status', 'varchar(32) NULL COMMENT ''报价状态:CONFIRMING/CONFIRMED/EXPIRED''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'quote_user_confirmed', 'tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''用户是否确认当前报价''');
|
||||
@@ -1910,7 +1911,7 @@ SELECT
|
||||
'xiaowang',
|
||||
0,
|
||||
0,
|
||||
'$2a$10$I3mV64NhISqMmm7soSki1.Y36ve.TOINGOrVt0U0kxjO7GtxavE16',
|
||||
'$2a$10$3ZC5HHVK6EYIfkjcU9IHZulGXwNZhy.6LU85HRJC9A.3LHm0IEdMO',
|
||||
'',
|
||||
'管理员',
|
||||
4,
|
||||
@@ -2311,3 +2312,14 @@ ON DUPLICATE KEY UPDATE
|
||||
is_delete = 0,
|
||||
update_by = VALUES(update_by),
|
||||
update_time = NOW();
|
||||
|
||||
-- 排班规则与例外
|
||||
CREATE TABLE IF NOT EXISTS t_artist_schedule_rule (
|
||||
id bigint unsigned NOT NULL COMMENT '排班规则ID', shop_id bigint unsigned NOT NULL COMMENT '店铺ID', artist_id bigint unsigned NOT NULL COMMENT '美甲师用户ID', preset_type varchar(32) NOT NULL COMMENT '预设类型', work_days varchar(32) NOT NULL COMMENT '工作星期,1-7逗号分隔', start_time time NOT NULL COMMENT '常规开始时间', end_time time NOT NULL COMMENT '常规结束时间', slot_minutes int NOT NULL DEFAULT 60 COMMENT '预约间隔分钟', capacity int NOT NULL DEFAULT 1 COMMENT '同一时间段容量', status tinyint NOT NULL DEFAULT 1 COMMENT '状态:1启用,0停用', remark varchar(255) NULL COMMENT '备注', create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', is_delete tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除', PRIMARY KEY (id), UNIQUE KEY uk_artist_schedule_rule_artist (shop_id, artist_id, is_delete), KEY idx_artist_schedule_rule_shop_status (shop_id, status, is_delete)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='美甲师常规排班规则表';
|
||||
CREATE TABLE IF NOT EXISTS t_artist_schedule_exception (
|
||||
id bigint unsigned NOT NULL COMMENT '排班例外ID', shop_id bigint unsigned NOT NULL COMMENT '店铺ID', artist_id bigint unsigned NOT NULL COMMENT '美甲师用户ID', work_date date NOT NULL COMMENT '例外日期', exception_type varchar(32) NOT NULL COMMENT '例外类型:REST/EXTRA_WORK/CHANGE_SHIFT', start_time time NULL COMMENT '例外开始时间', end_time time NULL COMMENT '例外结束时间', slot_minutes int NOT NULL DEFAULT 60 COMMENT '预约间隔分钟', capacity int NOT NULL DEFAULT 1 COMMENT '同一时间段容量', remark varchar(255) NULL COMMENT '备注', create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', is_delete tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除', PRIMARY KEY (id), UNIQUE KEY uk_artist_schedule_exception_date (shop_id, artist_id, work_date, is_delete), KEY idx_artist_schedule_exception_artist_date (artist_id, work_date, is_delete)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='美甲师排班例外表';
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
DROP TABLE IF EXISTS t_inventory_record; DROP TABLE IF EXISTS t_inventory_item; DROP TABLE IF EXISTS t_campaign; DROP TABLE IF EXISTS t_security_audit_log; DROP TABLE IF EXISTS t_user_shop_role; DROP TABLE IF EXISTS t_shop_role_permission; DROP TABLE IF EXISTS t_shop_role; DROP TABLE IF EXISTS t_user_permission; DROP TABLE IF EXISTS t_permission;
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
+13
-1
@@ -1732,6 +1732,7 @@ ON DUPLICATE KEY UPDATE
|
||||
is_delete = 0,
|
||||
update_time = NOW();
|
||||
|
||||
|
||||
CALL sp_add_column_if_not_exists('t_order', 'customer_remark', 'varchar(500) NULL COMMENT ''用户询价预约备注''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'quote_status', 'varchar(32) NULL COMMENT ''报价状态:CONFIRMING/CONFIRMED/EXPIRED''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'quote_user_confirmed', 'tinyint unsigned NOT NULL DEFAULT 0 COMMENT ''用户是否确认当前报价''');
|
||||
@@ -1910,7 +1911,7 @@ SELECT
|
||||
'xiaowang',
|
||||
0,
|
||||
0,
|
||||
'$2a$10$I3mV64NhISqMmm7soSki1.Y36ve.TOINGOrVt0U0kxjO7GtxavE16',
|
||||
'$2a$10$3ZC5HHVK6EYIfkjcU9IHZulGXwNZhy.6LU85HRJC9A.3LHm0IEdMO',
|
||||
'',
|
||||
'管理员',
|
||||
4,
|
||||
@@ -2311,3 +2312,14 @@ ON DUPLICATE KEY UPDATE
|
||||
is_delete = 0,
|
||||
update_by = VALUES(update_by),
|
||||
update_time = NOW();
|
||||
|
||||
-- 排班规则与例外
|
||||
CREATE TABLE IF NOT EXISTS t_artist_schedule_rule (
|
||||
id bigint unsigned NOT NULL COMMENT '排班规则ID', shop_id bigint unsigned NOT NULL COMMENT '店铺ID', artist_id bigint unsigned NOT NULL COMMENT '美甲师用户ID', preset_type varchar(32) NOT NULL COMMENT '预设类型', work_days varchar(32) NOT NULL COMMENT '工作星期,1-7逗号分隔', start_time time NOT NULL COMMENT '常规开始时间', end_time time NOT NULL COMMENT '常规结束时间', slot_minutes int NOT NULL DEFAULT 60 COMMENT '预约间隔分钟', capacity int NOT NULL DEFAULT 1 COMMENT '同一时间段容量', status tinyint NOT NULL DEFAULT 1 COMMENT '状态:1启用,0停用', remark varchar(255) NULL COMMENT '备注', create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', is_delete tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除', PRIMARY KEY (id), UNIQUE KEY uk_artist_schedule_rule_artist (shop_id, artist_id, is_delete), KEY idx_artist_schedule_rule_shop_status (shop_id, status, is_delete)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='美甲师常规排班规则表';
|
||||
CREATE TABLE IF NOT EXISTS t_artist_schedule_exception (
|
||||
id bigint unsigned NOT NULL COMMENT '排班例外ID', shop_id bigint unsigned NOT NULL COMMENT '店铺ID', artist_id bigint unsigned NOT NULL COMMENT '美甲师用户ID', work_date date NOT NULL COMMENT '例外日期', exception_type varchar(32) NOT NULL COMMENT '例外类型:REST/EXTRA_WORK/CHANGE_SHIFT', start_time time NULL COMMENT '例外开始时间', end_time time NULL COMMENT '例外结束时间', slot_minutes int NOT NULL DEFAULT 60 COMMENT '预约间隔分钟', capacity int NOT NULL DEFAULT 1 COMMENT '同一时间段容量', remark varchar(255) NULL COMMENT '备注', create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', is_delete tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除', PRIMARY KEY (id), UNIQUE KEY uk_artist_schedule_exception_date (shop_id, artist_id, work_date, is_delete), KEY idx_artist_schedule_exception_artist_date (artist_id, work_date, is_delete)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='美甲师排班例外表';
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
DROP TABLE IF EXISTS t_wishlist; DROP TABLE IF EXISTS t_wishlist_group; DROP TABLE IF EXISTS t_product_like; DROP TABLE IF EXISTS t_cart; DROP TABLE IF EXISTS t_vip_info; DROP TABLE IF EXISTS t_vip_benefit; DROP TABLE IF EXISTS t_user_growth_record; DROP TABLE IF EXISTS t_user_coupon; DROP TABLE IF EXISTS t_coupon_tag; DROP TABLE IF EXISTS t_coupon;
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -1,14 +0,0 @@
|
||||
-- 店务端职责裁剪:移除设计师用户侧购物车、收藏、会员和商品互动结构。
|
||||
-- 执行前必须完成 jayucloud_salon 数据库备份,并在维护窗口执行。
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
DROP TABLE IF EXISTS t_wishlist;
|
||||
DROP TABLE IF EXISTS t_wishlist_group;
|
||||
DROP TABLE IF EXISTS t_product_like;
|
||||
DROP TABLE IF EXISTS t_cart;
|
||||
DROP TABLE IF EXISTS t_vip_info;
|
||||
DROP TABLE IF EXISTS t_vip_benefit;
|
||||
DROP TABLE IF EXISTS t_user_growth_record;
|
||||
DROP TABLE IF EXISTS t_user_coupon;
|
||||
DROP TABLE IF EXISTS t_coupon_tag;
|
||||
DROP TABLE IF EXISTS t_coupon;
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -1,13 +0,0 @@
|
||||
-- 设计师端职责裁剪:移除仅店务管理使用的库存、营销活动和权限审计结构。
|
||||
-- 执行前必须完成 jayucloud_artlist 数据库备份,并在维护窗口执行。
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
DROP TABLE IF EXISTS t_inventory_record;
|
||||
DROP TABLE IF EXISTS t_inventory_item;
|
||||
DROP TABLE IF EXISTS t_campaign;
|
||||
DROP TABLE IF EXISTS t_security_audit_log;
|
||||
DROP TABLE IF EXISTS t_user_shop_role;
|
||||
DROP TABLE IF EXISTS t_shop_role_permission;
|
||||
DROP TABLE IF EXISTS t_shop_role;
|
||||
DROP TABLE IF EXISTS t_user_permission;
|
||||
DROP TABLE IF EXISTS t_permission;
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -1,92 +0,0 @@
|
||||
-- 员工排班规则和例外,保留 t_artist_schedule 作为预约校验使用的具体日期排班表。
|
||||
use fingertipdesigner;
|
||||
DROP PROCEDURE IF EXISTS sp_fd_add_index_if_not_exists;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE sp_fd_add_index_if_not_exists(
|
||||
IN p_table_name varchar(128),
|
||||
IN p_index_name varchar(128),
|
||||
IN p_index_sql varchar(1000)
|
||||
)
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = p_table_name
|
||||
AND index_name = p_index_name
|
||||
) THEN
|
||||
SET @fd_sql = CONCAT('ALTER TABLE ', p_table_name, ' ADD INDEX ', p_index_name, ' ', p_index_sql);
|
||||
PREPARE fd_stmt FROM @fd_sql;
|
||||
EXECUTE fd_stmt;
|
||||
DEALLOCATE PREPARE fd_stmt;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
DROP PROCEDURE IF EXISTS sp_fd_add_unique_index_if_not_exists;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE sp_fd_add_unique_index_if_not_exists(
|
||||
IN p_table_name varchar(128),
|
||||
IN p_index_name varchar(128),
|
||||
IN p_index_sql varchar(1000)
|
||||
)
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM information_schema.statistics
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = p_table_name
|
||||
AND index_name = p_index_name
|
||||
) THEN
|
||||
SET @fd_sql = CONCAT('ALTER TABLE ', p_table_name, ' ADD UNIQUE INDEX ', p_index_name, ' ', p_index_sql);
|
||||
PREPARE fd_stmt FROM @fd_sql;
|
||||
EXECUTE fd_stmt;
|
||||
DEALLOCATE PREPARE fd_stmt;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_artist_schedule_rule
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '排班规则ID',
|
||||
shop_id bigint unsigned NOT NULL COMMENT '店铺ID',
|
||||
artist_id bigint unsigned NOT NULL COMMENT '美甲师用户ID',
|
||||
preset_type varchar(32) NOT NULL COMMENT '预设类型',
|
||||
work_days varchar(32) NOT NULL COMMENT '工作星期,1-7逗号分隔',
|
||||
start_time time NOT NULL COMMENT '常规开始时间',
|
||||
end_time time NOT NULL COMMENT '常规结束时间',
|
||||
slot_minutes int NOT NULL DEFAULT 60 COMMENT '预约间隔分钟',
|
||||
capacity int NOT NULL DEFAULT 1 COMMENT '同一时间段容量',
|
||||
status tinyint NOT NULL DEFAULT 1 COMMENT '状态:1启用,0停用',
|
||||
remark varchar(255) NULL COMMENT '备注',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
is_delete tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='美甲师常规排班规则表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_artist_schedule_exception
|
||||
(
|
||||
id bigint unsigned NOT NULL COMMENT '排班例外ID',
|
||||
shop_id bigint unsigned NOT NULL COMMENT '店铺ID',
|
||||
artist_id bigint unsigned NOT NULL COMMENT '美甲师用户ID',
|
||||
work_date date NOT NULL COMMENT '例外日期',
|
||||
exception_type varchar(32) NOT NULL COMMENT '例外类型:REST/EXTRA_WORK/CHANGE_SHIFT',
|
||||
start_time time NULL COMMENT '例外开始时间',
|
||||
end_time time NULL COMMENT '例外结束时间',
|
||||
slot_minutes int NOT NULL DEFAULT 60 COMMENT '预约间隔分钟',
|
||||
capacity int NOT NULL DEFAULT 1 COMMENT '同一时间段容量',
|
||||
remark varchar(255) NULL COMMENT '备注',
|
||||
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
is_delete tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='美甲师排班例外表';
|
||||
|
||||
CALL sp_fd_add_unique_index_if_not_exists('t_artist_schedule_rule', 'uk_artist_schedule_rule_artist', '(`shop_id`, `artist_id`, `is_delete`)');
|
||||
CALL sp_fd_add_index_if_not_exists('t_artist_schedule_rule', 'idx_artist_schedule_rule_shop_status', '(`shop_id`, `status`, `is_delete`)');
|
||||
CALL sp_fd_add_unique_index_if_not_exists('t_artist_schedule_exception', 'uk_artist_schedule_exception_date', '(`shop_id`, `artist_id`, `work_date`, `is_delete`)');
|
||||
CALL sp_fd_add_index_if_not_exists('t_artist_schedule_exception', 'idx_artist_schedule_exception_artist_date', '(`artist_id`, `work_date`, `is_delete`)');
|
||||
|
||||
DROP PROCEDURE IF EXISTS sp_fd_add_index_if_not_exists;
|
||||
DROP PROCEDURE IF EXISTS sp_fd_add_unique_index_if_not_exists;
|
||||
Reference in New Issue
Block a user