fix(payment): 补升 schema 版本使售后举证图片列在已安装站点生效
order_aftersale 新增 images 列时未同步升 SCHEMA_VERSION,而 dbDelta 只在版本 变化时重跑,已安装站点不会执行 ALTER TABLE,提交售后申请直接报 Unknown column 'images'。SCHEMA_VERSION 2.5.0 -> 2.5.1,并在契约测试中 锁定「列变更必须同步升版本」,部署后进入一次 wp-admin 即自动补列。
This commit is contained in:
1 parent
1a9a2762f3
commit
4ea02f25ac
2 files changed
+14
-1
No files matched your search
@@ -14,7 +14,9 @@ class DBMigrator {
|
|||||||
use DBMigratorVip;
|
use DBMigratorVip;
|
||||||
|
|
||||||
/** Current schema version; changing it re-runs dbDelta. */
|
/** Current schema version; changing it re-runs dbDelta. */
|
||||||
const SCHEMA_VERSION = '2.5.0';
|
// 2.5.1: order_aftersale 新增 images 列(售后举证图片)。dbDelta 仅在版本变化时
|
||||||
|
// 重跑,新增/调整列必须同步升版本,否则老安装不会执行 ALTER TABLE。
|
||||||
|
const SCHEMA_VERSION = '2.5.1';
|
||||||
|
|
||||||
const OPT_KEY = 'aksrt_db_schema_version';
|
const OPT_KEY = 'aksrt_db_schema_version';
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,17 @@ test('after-sale tickets persist evidence images and expose the latest row', ()
|
|||||||
const schema = read('src/Core/DBMigratorPart2.php')
|
const schema = read('src/Core/DBMigratorPart2.php')
|
||||||
assert.match(schema, /CREATE TABLE \{\$prefix\}aksrt_order_aftersale[\s\S]*?images LONGTEXT DEFAULT NULL[\s\S]*?refund_amount/)
|
assert.match(schema, /CREATE TABLE \{\$prefix\}aksrt_order_aftersale[\s\S]*?images LONGTEXT DEFAULT NULL[\s\S]*?refund_amount/)
|
||||||
|
|
||||||
|
// images 列随 schema 2.5.1 引入:dbDelta 只在版本变化时重跑,列变更必须同步升版本,
|
||||||
|
// 否则老安装不会 ALTER TABLE,写入直接报 Unknown column 'images'。
|
||||||
|
const migrator = read('src/Core/DBMigrator.php')
|
||||||
|
const version = migrator.match(/const SCHEMA_VERSION = '(\d+)\.(\d+)\.(\d+)'/)
|
||||||
|
assert.ok(version, 'DBMigrator exposes a numeric SCHEMA_VERSION')
|
||||||
|
const [major, minor, patch] = version.slice(1).map(Number)
|
||||||
|
assert.ok(
|
||||||
|
major > 2 || (major === 2 && minor > 5) || (major === 2 && minor === 5 && patch >= 1),
|
||||||
|
`SCHEMA_VERSION must be at least 2.5.1 after adding order_aftersale.images, got ${major}.${minor}.${patch}`
|
||||||
|
)
|
||||||
|
|
||||||
const service = read('src/Payment/AfterSaleService.php')
|
const service = read('src/Payment/AfterSaleService.php')
|
||||||
assert.match(service, /public function create\(int \$user_id, string \$order_number, string \$reason, array \$images = \[\]\)/)
|
assert.match(service, /public function create\(int \$user_id, string \$order_number, string \$reason, array \$images = \[\]\)/)
|
||||||
assert.match(service, /\$images = \$this->sanitize_images\(\$images\);/)
|
assert.match(service, /\$images = \$this->sanitize_images\(\$images\);/)
|
||||||
|
|||||||
Reference in new issue
Block a user