koishi-plugin-wordpress-notifier 2.8.3 → 2.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/lib/index.js +60 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -389,6 +389,28 @@ npm install
|
|
|
389
389
|
|
|
390
390
|
## 版本历史
|
|
391
391
|
|
|
392
|
+
### 2.8.5 (2026-02-19)
|
|
393
|
+
|
|
394
|
+
- 🐛 修复 MySQL 主键约束错误 (ER_PRIMARY_CANT_HAVE_NULL)
|
|
395
|
+
|
|
396
|
+
**核心修复**
|
|
397
|
+
- ✅ 增强 `checkAndFixTableStructure` 函数,添加对 `wordpress_version` 表的验证和修复逻辑
|
|
398
|
+
- ✅ 确保所有数据库表的主键约束正确设置,避免 NULL 值问题
|
|
399
|
+
- ✅ 优化表结构初始化过程,确保所有表都能正确创建和初始化
|
|
400
|
+
|
|
401
|
+
**稳定性提升**
|
|
402
|
+
- ✅ 提高插件在 MySQL 数据库环境下的稳定性
|
|
403
|
+
- ✅ 增强数据库表结构异常情况下的恢复能力
|
|
404
|
+
|
|
405
|
+
### 2.8.4 (2026-02-19)
|
|
406
|
+
|
|
407
|
+
- 🔧 版本更新和文档完善
|
|
408
|
+
|
|
409
|
+
**更新内容**
|
|
410
|
+
- ✅ 更新版本号到 2.8.4
|
|
411
|
+
- ✅ 完善 README.md 文档
|
|
412
|
+
- ✅ 确保插件稳定性和可靠性
|
|
413
|
+
|
|
392
414
|
### 2.8.3 (2026-02-19)
|
|
393
415
|
|
|
394
416
|
- 🐛 修复数据库表结构初始化问题
|
package/lib/index.js
CHANGED
|
@@ -129,22 +129,23 @@ function apply(ctx, config) {
|
|
|
129
129
|
ctx.logger.info('WordPress 推送插件已加载');
|
|
130
130
|
// 修复 MySQL 自增主键问题,使用正确的模型配置
|
|
131
131
|
// 确保 id 字段被正确设置为自增主键,并且在插入时不会被设置为 NULL
|
|
132
|
+
// 显式指定 NOT NULL 约束以适配 MySQL 特有要求
|
|
132
133
|
ctx.model.extend('wordpress_post_updates', {
|
|
133
|
-
id: 'integer',
|
|
134
|
-
siteId: 'string',
|
|
135
|
-
postId: 'integer',
|
|
136
|
-
lastModified: 'timestamp',
|
|
137
|
-
pushedAt: 'timestamp'
|
|
134
|
+
id: { type: 'integer', nullable: false },
|
|
135
|
+
siteId: { type: 'string', nullable: false },
|
|
136
|
+
postId: { type: 'integer', nullable: false },
|
|
137
|
+
lastModified: { type: 'timestamp', nullable: false },
|
|
138
|
+
pushedAt: { type: 'timestamp', nullable: false }
|
|
138
139
|
}, {
|
|
139
140
|
primary: 'id',
|
|
140
141
|
autoInc: true,
|
|
141
142
|
unique: ['siteId', 'postId'] // 每个站点的文章 ID 唯一
|
|
142
143
|
});
|
|
143
144
|
ctx.model.extend('wordpress_user_registrations', {
|
|
144
|
-
id: 'integer',
|
|
145
|
-
siteId: 'string',
|
|
146
|
-
userId: 'integer',
|
|
147
|
-
pushedAt: 'timestamp'
|
|
145
|
+
id: { type: 'integer', nullable: false },
|
|
146
|
+
siteId: { type: 'string', nullable: false },
|
|
147
|
+
userId: { type: 'integer', nullable: false },
|
|
148
|
+
pushedAt: { type: 'timestamp', nullable: false }
|
|
148
149
|
}, {
|
|
149
150
|
primary: 'id',
|
|
150
151
|
autoInc: true,
|
|
@@ -152,10 +153,10 @@ function apply(ctx, config) {
|
|
|
152
153
|
});
|
|
153
154
|
// 配置存储表
|
|
154
155
|
ctx.model.extend('wordpress_config', {
|
|
155
|
-
id: 'integer',
|
|
156
|
-
key: 'string',
|
|
157
|
-
value: 'string',
|
|
158
|
-
updatedAt: 'timestamp'
|
|
156
|
+
id: { type: 'integer', nullable: false },
|
|
157
|
+
key: { type: 'string', nullable: false },
|
|
158
|
+
value: { type: 'string', nullable: false },
|
|
159
|
+
updatedAt: { type: 'timestamp', nullable: false }
|
|
159
160
|
}, {
|
|
160
161
|
primary: 'id',
|
|
161
162
|
autoInc: true,
|
|
@@ -163,9 +164,9 @@ function apply(ctx, config) {
|
|
|
163
164
|
});
|
|
164
165
|
// 版本记录表
|
|
165
166
|
ctx.model.extend('wordpress_version', {
|
|
166
|
-
id: 'integer',
|
|
167
|
-
version: 'string',
|
|
168
|
-
updatedAt: 'timestamp'
|
|
167
|
+
id: { type: 'integer', nullable: false },
|
|
168
|
+
version: { type: 'string', nullable: false },
|
|
169
|
+
updatedAt: { type: 'timestamp', nullable: false }
|
|
169
170
|
}, {
|
|
170
171
|
primary: 'id',
|
|
171
172
|
autoInc: true,
|
|
@@ -532,11 +533,11 @@ function apply(ctx, config) {
|
|
|
532
533
|
ctx.logger.info('旧表删除成功,重新初始化表结构...');
|
|
533
534
|
// 重新扩展模型
|
|
534
535
|
ctx.model.extend('wordpress_post_updates', {
|
|
535
|
-
id: 'integer',
|
|
536
|
-
siteId: 'string',
|
|
537
|
-
postId: 'integer',
|
|
538
|
-
lastModified: 'timestamp',
|
|
539
|
-
pushedAt: 'timestamp'
|
|
536
|
+
id: { type: 'integer', nullable: false },
|
|
537
|
+
siteId: { type: 'string', nullable: false },
|
|
538
|
+
postId: { type: 'integer', nullable: false },
|
|
539
|
+
lastModified: { type: 'timestamp', nullable: false },
|
|
540
|
+
pushedAt: { type: 'timestamp', nullable: false }
|
|
540
541
|
}, {
|
|
541
542
|
primary: 'id',
|
|
542
543
|
autoInc: true,
|
|
@@ -564,10 +565,10 @@ function apply(ctx, config) {
|
|
|
564
565
|
ctx.logger.info('旧表删除成功,重新初始化表结构...');
|
|
565
566
|
// 重新扩展模型
|
|
566
567
|
ctx.model.extend('wordpress_user_registrations', {
|
|
567
|
-
id: 'integer',
|
|
568
|
-
siteId: 'string',
|
|
569
|
-
userId: 'integer',
|
|
570
|
-
pushedAt: 'timestamp'
|
|
568
|
+
id: { type: 'integer', nullable: false },
|
|
569
|
+
siteId: { type: 'string', nullable: false },
|
|
570
|
+
userId: { type: 'integer', nullable: false },
|
|
571
|
+
pushedAt: { type: 'timestamp', nullable: false }
|
|
571
572
|
}, {
|
|
572
573
|
primary: 'id',
|
|
573
574
|
autoInc: true,
|
|
@@ -595,10 +596,10 @@ function apply(ctx, config) {
|
|
|
595
596
|
ctx.logger.info('旧表删除成功,重新初始化表结构...');
|
|
596
597
|
// 重新扩展模型
|
|
597
598
|
ctx.model.extend('wordpress_config', {
|
|
598
|
-
id: 'integer',
|
|
599
|
-
key: 'string',
|
|
600
|
-
value: 'string',
|
|
601
|
-
updatedAt: 'timestamp'
|
|
599
|
+
id: { type: 'integer', nullable: false },
|
|
600
|
+
key: { type: 'string', nullable: false },
|
|
601
|
+
value: { type: 'string', nullable: false },
|
|
602
|
+
updatedAt: { type: 'timestamp', nullable: false }
|
|
602
603
|
}, {
|
|
603
604
|
primary: 'id',
|
|
604
605
|
autoInc: true,
|
|
@@ -610,6 +611,36 @@ function apply(ctx, config) {
|
|
|
610
611
|
ctx.logger.warn(`删除旧表失败,可能表不存在:${dropError}`);
|
|
611
612
|
}
|
|
612
613
|
}
|
|
614
|
+
try {
|
|
615
|
+
ctx.logger.info('验证 wordpress_version 表结构...');
|
|
616
|
+
const testVersion = await ctx.database.get('wordpress_version', {}, {
|
|
617
|
+
limit: 1
|
|
618
|
+
});
|
|
619
|
+
ctx.logger.info(`wordpress_version 表验证成功,现有记录数:${testVersion.length}`);
|
|
620
|
+
}
|
|
621
|
+
catch (error) {
|
|
622
|
+
ctx.logger.warn(`wordpress_version 表可能结构不正确,尝试重新初始化...`);
|
|
623
|
+
// 尝试删除旧表并重新初始化
|
|
624
|
+
try {
|
|
625
|
+
ctx.logger.info('尝试删除旧的 wordpress_version 表...');
|
|
626
|
+
await ctx.database.drop('wordpress_version');
|
|
627
|
+
ctx.logger.info('旧表删除成功,重新初始化表结构...');
|
|
628
|
+
// 重新扩展模型
|
|
629
|
+
ctx.model.extend('wordpress_version', {
|
|
630
|
+
id: { type: 'integer', nullable: false },
|
|
631
|
+
version: { type: 'string', nullable: false },
|
|
632
|
+
updatedAt: { type: 'timestamp', nullable: false }
|
|
633
|
+
}, {
|
|
634
|
+
primary: 'id',
|
|
635
|
+
autoInc: true,
|
|
636
|
+
unique: ['version']
|
|
637
|
+
});
|
|
638
|
+
ctx.logger.info('wordpress_version 表重新初始化成功');
|
|
639
|
+
}
|
|
640
|
+
catch (dropError) {
|
|
641
|
+
ctx.logger.warn(`删除旧表失败,可能表不存在:${dropError}`);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
613
644
|
ctx.logger.info('表结构检查和修复完成');
|
|
614
645
|
}
|
|
615
646
|
catch (error) {
|