Files
go_blog/scripts/drop_attachments_table.sql
T
dsh 970dbd4c5b refactor: 上传/下载接口全面迁移到统一 files 表,移除 attachments 模型
- 删除 models/attachment.go,Attachment 模型由 File(Type=attachments)替代
- handlers/attachment.go:上传/删除/列表/绑定全部改读写 files 表,
  查询按 type='attachments' 过滤(为 avatar/logo 等类型预留隔离)
- models/db.go:AutoMigrate 移除 Attachment;启动迁移仅当旧表仍存在时执行
  (升级路径保障,已删除则为无操作)
- 测试同步切换到 File 模型(security_test/bodylimit_test)
- scripts/drop_attachments_table.sql:旧表删除脚本(含前置校验说明)
2026-08-28 19:23:50 +08:00

12 lines
588 B
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.
-- Migration: 删除旧 attachments 表(数据已迁移至统一 files 表,type='attachments'
-- Date: 2026-08-28
-- 前置条件:已部署使用 files 表的新版 blog_go 并完成验证(启动迁移会把
-- 尚未搬运的 attachments 行复制进 files)。本脚本幂等,可安全重跑。
--
-- 执行前确认:
-- SELECT COUNT(*) AS remaining FROM attachments a
-- WHERE NOT EXISTS (SELECT 1 FROM files f WHERE f.id = a.id);
-- 结果应为 0——若有遗留行,先重启新版本服务让其自动搬运。
DROP TABLE IF EXISTS `attachments`;