feat(users): add native VIP management
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1bd09dcda3
commit
703eedfba1
9 files changed
+570
-1
No files matched your search
@@ -11,9 +11,10 @@ class DBMigrator {
|
||||
use DBMigratorPart2;
|
||||
use DBMigratorPart3;
|
||||
use DBMigratorIdentity;
|
||||
use DBMigratorVip;
|
||||
|
||||
/** Current schema version; changing it re-runs dbDelta. */
|
||||
const SCHEMA_VERSION = '1.20.0';
|
||||
const SCHEMA_VERSION = '1.21.0';
|
||||
|
||||
const OPT_KEY = 'aksrt_db_schema_version';
|
||||
|
||||
|
||||
@@ -401,5 +401,6 @@ trait DBMigratorPart2 {
|
||||
dbDelta($sql_order_items);
|
||||
|
||||
self::migrate_identity_tables($prefix, $charset_collate);
|
||||
self::migrate_vip_tables($prefix, $charset_collate);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ trait DBMigratorPart3 {
|
||||
'user_restriction' => 'aksrt_user_restriction',
|
||||
'identity_application' => 'aksrt_identity_application',
|
||||
'identity_event' => 'aksrt_identity_event',
|
||||
'vip_membership_event' => 'aksrt_vip_membership_event',
|
||||
];
|
||||
if (!isset($allowed[$name])) {
|
||||
return '';
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* VIP membership audit table.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
trait DBMigratorVip {
|
||||
|
||||
private static function migrate_vip_tables(string $prefix, string $charset_collate): void {
|
||||
$event = "CREATE TABLE {$prefix}aksrt_vip_membership_event (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
event_uuid CHAR(36) NOT NULL,
|
||||
batch_uuid CHAR(36) NOT NULL DEFAULT '',
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
actor_user_id BIGINT UNSIGNED DEFAULT NULL,
|
||||
operation VARCHAR(16) NOT NULL,
|
||||
source VARCHAR(20) NOT NULL DEFAULT 'admin',
|
||||
reason VARCHAR(255) NOT NULL DEFAULT '',
|
||||
request_json LONGTEXT DEFAULT NULL,
|
||||
before_json LONGTEXT DEFAULT NULL,
|
||||
after_json LONGTEXT DEFAULT NULL,
|
||||
status VARCHAR(16) NOT NULL DEFAULT 'pending',
|
||||
error_code VARCHAR(64) NOT NULL DEFAULT '',
|
||||
error_message VARCHAR(255) NOT NULL DEFAULT '',
|
||||
created_at DATETIME NOT NULL,
|
||||
completed_at DATETIME DEFAULT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uniq_event_uuid (event_uuid),
|
||||
KEY idx_user_created (user_id, created_at),
|
||||
KEY idx_actor_created (actor_user_id, created_at),
|
||||
KEY idx_batch (batch_uuid),
|
||||
KEY idx_status_created (status, created_at),
|
||||
KEY idx_operation_created (operation, created_at)
|
||||
) {$charset_collate};";
|
||||
dbDelta($event);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user