Files
oil/server-tp6/deploy/db_reset_dev.sql
T

125 lines
5.6 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.
-- ============================================================
-- 开发/联调环境 数据库初始化清理脚本
-- 生成:2026-09-06
-- 作用:清空业务与测试流水,保留系统运行所需的账号、权限、字典、设置
-- ⚠️ 执行前务必备份:mysqldump -uroot -p oil > backup.sql
-- ============================================================
SET FOREIGN_KEY_CHECKS = 0;
-- ------------------------------------------------------------
-- 1. 企油通 / 合作商 业务流水
-- 注意:yoshop_partners(下游接口账户:orgNo/appKey/RSA密钥/回调地址)予以保留
-- ------------------------------------------------------------
TRUNCATE TABLE `yoshop_partners_order`;
TRUNCATE TABLE `yoshop_qyt_consume`;
TRUNCATE TABLE `yoshop_partners_balance_log`;
TRUNCATE TABLE `yoshop_partners_goods`;
TRUNCATE TABLE `yoshop_partners_stock_log`;
-- ------------------------------------------------------------
-- 2. 商城订单与售后
-- ------------------------------------------------------------
TRUNCATE TABLE `yoshop_order`;
TRUNCATE TABLE `yoshop_order_goods`;
TRUNCATE TABLE `yoshop_order_address`;
TRUNCATE TABLE `yoshop_order_qrcode`;
TRUNCATE TABLE `yoshop_order_record`;
TRUNCATE TABLE `yoshop_order_refund`;
TRUNCATE TABLE `yoshop_order_refund_address`;
TRUNCATE TABLE `yoshop_order_refund_image`;
TRUNCATE TABLE `yoshop_order_export`;
-- ------------------------------------------------------------
-- 3. 接口请求日志 / 已停用模块(分油公司、分油用户池)
-- ------------------------------------------------------------
TRUNCATE TABLE `yoshop_request_log`;
TRUNCATE TABLE `yoshop_account`;
TRUNCATE TABLE `yoshop_company`;
TRUNCATE TABLE `yoshop_company_balance_log`;
-- ------------------------------------------------------------
-- 4. 购物车 / 结算 / 兑换卡 / 充值
-- ------------------------------------------------------------
TRUNCATE TABLE `yoshop_cart`;
TRUNCATE TABLE `yoshop_checkout`;
TRUNCATE TABLE `yoshop_card`;
TRUNCATE TABLE `yoshop_card_log`;
TRUNCATE TABLE `yoshop_card_print`;
TRUNCATE TABLE `yoshop_recharge_order`;
TRUNCATE TABLE `yoshop_recharge_order_plan`;
TRUNCATE TABLE `yoshop_recharge_plan`;
-- ------------------------------------------------------------
-- 5. 商户 / 代理商体系(支付聚合链路)
-- ------------------------------------------------------------
TRUNCATE TABLE `yoshop_merchant`;
TRUNCATE TABLE `yoshop_merchant_balance_log`;
TRUNCATE TABLE `yoshop_merchant_order`;
-- ------------------------------------------------------------
-- 6. 小程序用户及其附属数据(保留 yoshop_user_grade 等级配置)
-- ------------------------------------------------------------
TRUNCATE TABLE `yoshop_user`;
TRUNCATE TABLE `yoshop_user_oauth`;
TRUNCATE TABLE `yoshop_user_address`;
TRUNCATE TABLE `yoshop_user_balance_log`;
TRUNCATE TABLE `yoshop_user_coupon`;
TRUNCATE TABLE `yoshop_user_grade_log`;
TRUNCATE TABLE `yoshop_user_points_log`;
TRUNCATE TABLE `yoshop_user_commission_log`;
-- ------------------------------------------------------------
-- 7. 商城基础数据(商品 / 分类 / 优惠券 / 装修页 / 文件库)
-- 注意:图片物理文件仍在磁盘,仅清库记录
-- ------------------------------------------------------------
TRUNCATE TABLE `yoshop_goods`;
TRUNCATE TABLE `yoshop_goods_sku`;
TRUNCATE TABLE `yoshop_goods_image`;
TRUNCATE TABLE `yoshop_goods_category_rel`;
TRUNCATE TABLE `yoshop_goods_service_rel`;
TRUNCATE TABLE `yoshop_goods_spec_rel`;
TRUNCATE TABLE `yoshop_goods_coupon`;
TRUNCATE TABLE `yoshop_category`;
TRUNCATE TABLE `yoshop_coupon`;
TRUNCATE TABLE `yoshop_page`;
TRUNCATE TABLE `yoshop_upload_file`;
-- ------------------------------------------------------------
-- 8. 其余业务表
-- ------------------------------------------------------------
TRUNCATE TABLE `yoshop_notify`;
TRUNCATE TABLE `yoshop_code`;
TRUNCATE TABLE `yoshop_comment`;
TRUNCATE TABLE `yoshop_comment_image`;
-- ------------------------------------------------------------
-- 9. 后台账号:只保留超级管理员 admin(store_user_id=10001)
-- ------------------------------------------------------------
DELETE FROM `yoshop_store_user` WHERE `store_user_id` <> 10001;
DELETE FROM `yoshop_store_user_role` WHERE `store_user_id` <> 10001;
-- ------------------------------------------------------------
-- 10. 恢复 yoshop 惯用的自增起始值(10001)
-- ------------------------------------------------------------
ALTER TABLE `yoshop_cart` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_category` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_coupon` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_goods` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_goods_category_rel` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_goods_image` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_goods_service_rel` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_goods_sku` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_merchant_order` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_order` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_order_goods` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_page` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_upload_file` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_user` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_user_address` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_user_balance_log` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_user_coupon` AUTO_INCREMENT = 10001;
ALTER TABLE `yoshop_user_oauth` AUTO_INCREMENT = 10001;
SET FOREIGN_KEY_CHECKS = 1;