peixue-dev/peidu/Archive/一次性文件/[一次性]检查并修复旧图片URL-2026-01-25.sql

36 lines
1.4 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.

-- 检查并修复数据库中的旧图片URL
-- 2026-01-25
-- 1. 检查banner表中的示例数据
SELECT * FROM banner WHERE image_url LIKE '%example.com%';
-- 2. 检查所有表中包含旧URL的记录
-- 检查service表
SELECT id, name, image FROM service WHERE image LIKE '%localhost:8080%' OR image LIKE '%:8080/uploads%';
-- 检查banner表
SELECT id, title, image_url FROM banner WHERE image_url LIKE '%localhost:8080%' OR image_url LIKE '%:8080/uploads%';
-- 检查learning_record表
SELECT id, images, videos FROM learning_record WHERE images LIKE '%localhost:8080%' OR images LIKE '%:8080/uploads%';
-- 检查teacher表
SELECT id, teacher_name, avatar FROM teacher WHERE avatar LIKE '%localhost:8080%' OR avatar LIKE '%:8080/uploads%';
-- 检查student表
SELECT id, student_name, avatar FROM student WHERE avatar LIKE '%localhost:8080%' OR avatar LIKE '%:8080/uploads%';
-- 3. 修复banner表的示例数据(如果存在)
UPDATE banner
SET image_url = 'https://px.ddn-ai.cloud/uploads/default_banner.jpg'
WHERE image_url LIKE '%example.com%';
-- 4. 说明旧的URL格式需要手动处理
-- 旧格式: http://localhost:8080/uploads/images/2026/01/08/xxx.png
-- 新格式: https://px.ddn-ai.cloud/uploads/20260125_xxx.png
--
-- 由于文件名格式不同,无法自动批量替换
-- 建议:
-- 1. 重新上传重要图片
-- 2. 或者手动迁移旧图片到新目录并更新URL