feat(payment): schema 版本升至 2.5.2(apply_form 列迁移)
This commit is contained in:
+44
-43
@@ -1,43 +1,44 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @package AKSRT
|
* @package AKSRT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace AKSRT\Core;
|
namespace AKSRT\Core;
|
||||||
|
|
||||||
defined('ABSPATH') || exit;
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
class DBMigrator {
|
class DBMigrator {
|
||||||
use DBMigratorPart2;
|
use DBMigratorPart2;
|
||||||
use DBMigratorPart3;
|
use DBMigratorPart3;
|
||||||
use DBMigratorIdentity;
|
use DBMigratorIdentity;
|
||||||
use DBMigratorVip;
|
use DBMigratorVip;
|
||||||
|
|
||||||
/** Current schema version; changing it re-runs dbDelta. */
|
/** Current schema version; changing it re-runs dbDelta. */
|
||||||
// 2.5.1: order_aftersale 新增 images 列(售后举证图片)。dbDelta 仅在版本变化时
|
// 2.5.1: order_aftersale 新增 images 列(售后举证图片)。dbDelta 仅在版本变化时
|
||||||
// 重跑,新增/调整列必须同步升版本,否则老安装不会执行 ALTER TABLE。
|
// 重跑,新增/调整列必须同步升版本,否则老安装不会执行 ALTER TABLE。
|
||||||
const SCHEMA_VERSION = '2.5.1';
|
// 2.5.2: order_aftersale 新增 apply_form 列(结构化申请表单:预置原因 / 申请资料 / 申请说明)。
|
||||||
|
const SCHEMA_VERSION = '2.5.2';
|
||||||
const OPT_KEY = 'aksrt_db_schema_version';
|
|
||||||
|
const OPT_KEY = 'aksrt_db_schema_version';
|
||||||
/**
|
|
||||||
* Register hooks.
|
/**
|
||||||
*/
|
* Register hooks.
|
||||||
public static function init(): void {
|
*/
|
||||||
add_action('after_switch_theme', [self::class, 'maybe_migrate']);
|
public static function init(): void {
|
||||||
add_action('admin_init', [self::class, 'maybe_migrate']);
|
add_action('after_switch_theme', [self::class, 'maybe_migrate']);
|
||||||
}
|
add_action('admin_init', [self::class, 'maybe_migrate']);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Run table schema upgrade when version mismatches.
|
/**
|
||||||
*/
|
* Run table schema upgrade when version mismatches.
|
||||||
public static function maybe_migrate(): void {
|
*/
|
||||||
$current = get_option(self::OPT_KEY, '');
|
public static function maybe_migrate(): void {
|
||||||
if ($current === self::SCHEMA_VERSION) {
|
$current = get_option(self::OPT_KEY, '');
|
||||||
return;
|
if ($current === self::SCHEMA_VERSION) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
self::run();
|
|
||||||
update_option(self::OPT_KEY, self::SCHEMA_VERSION);
|
self::run();
|
||||||
}
|
update_option(self::OPT_KEY, self::SCHEMA_VERSION);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user