Files
wordpress-theme-aksrt/src/Core/DBMigratorVip.php
T

43 lines
1.5 KiB
PHP

<?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)
) ENGINE=InnoDB {$charset_collate};";
dbDelta($event);
}
}