Split post content to new table and support content version control
Created by: guqing
What this PR does?
- 将文章内容从文章表中拆分出去
- 增加文章内容版本表用来存储内容版本增量记录
- 修改原有文章编辑逻辑后台编辑时不影响前台预览,只有发布后才能在前台展示最新内容
Why we need it?
How to test it?
- 针对Post和Sheet做保存和发布操作,期望内容不会出现丢失,保存草稿时期望不会在前台显示只有发布后才会同步到前台
- 做发布操作后观察数据库中content_patch_logs表中的version,期望值随发布次数递增
- 后台点击预览时期望查看到最新内容
- 后台文章列表和文章详情接口期望返回
inProgress
字段 - 先使用1.4.17版本启动实例,登陆到后台创建各种状态的文章和页面,然后切换到该PR再次启动会执行迁移脚本,观察数据库,期望看到contents和contents_patch_logs表并且表中存在数据,再次登陆后台对文章进行保存和发布,期望文章内容和未使用该PR启动时一致且操作不会报错且前台文章列表和内容详情显示正常。
- 登陆后台分别创建页面及文章,观察未发布过的草稿文章在content_patch_logs中的记录sourceId为0,发布过的文章最新的content_patch_logs记录为该文章上一条content_patch_logs记录的id
Remark
对ContentPatchLog添加表索引测试情景如下: 1.Finds patchlogs by post id and status order by version
explain
select *
from content_patch_logs
where post_id = 3
and status = 1 order by version desc;
id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
---|---|---|---|---|---|---|---|---|---|
1 | SIMPLE | content_patch_logs | ref|filter | idx_post_id,idx_status | idx_status|idx_post_id | 5|5 | const | 1 (63%) | Using where; Using filesort; Using rowid filter |
2.Finds patchlogs by post id and status and version order by version
explain
select *
from content_patch_logs
where post_id = 3
and status = 0 and version=3 order by version desc ;
id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
---|---|---|---|---|---|---|---|---|---|
1 | SIMPLE | content_patch_logs | ref|filter | idx_post_id,idx_status,idx_version | idx_version|idx_post_id | 4|5 | const | 1 (63%) | Using where; Using rowid filter |
3.Finds patchlogs by post id
explain
select *
from content_patch_logs
where post_id = 2;
id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
---|---|---|---|---|---|---|---|---|---|
1 | SIMPLE | content_patch_logs | ref | idx_post_id | idx_post_id | 5 | const | 1 |