Files
wordpress-theme-aksrt/src/Core/DBMigratorIdentity.php
T
kate522 8c5b1555c9 refactor: flatten src/AKSRT → src (drop theme-identifier dir)
Move all domain folders from src/AKSRT/{Domain} to src/{Domain}; remap
Composer PSR-4 "AKSRT\\": "src/"; update audit script + README + ADR
paths; remove dead tools/build-psr4-map.php (scanned deleted inc/classes).
2026-08-02 22:06:06 +08:00

88 lines
3.9 KiB
PHP

<?php
/**
* Identity verification tables.
*
* @package AKSRT
*/
namespace AKSRT\Core;
defined('ABSPATH') || exit;
trait DBMigratorIdentity {
private static function migrate_identity_tables(string $prefix, string $charset_collate): void {
$application = "CREATE TABLE {$prefix}aksrt_identity_application (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
application_uuid CHAR(36) NOT NULL,
client_request_id CHAR(36) NOT NULL,
user_id BIGINT UNSIGNED NOT NULL,
type VARCHAR(20) NOT NULL,
channel VARCHAR(20) NOT NULL DEFAULT 'cloud',
provider VARCHAR(20) NOT NULL DEFAULT '',
provider_flow VARCHAR(80) NOT NULL DEFAULT '',
provider_session_id VARCHAR(191) NOT NULL DEFAULT '',
provider_request_id VARCHAR(191) NOT NULL DEFAULT '',
redirect_url TEXT DEFAULT NULL,
qr_payload TEXT DEFAULT NULL,
status VARCHAR(32) NOT NULL DEFAULT 'created',
public_name VARCHAR(64) NOT NULL DEFAULT '',
public_desc VARCHAR(300) NOT NULL DEFAULT '',
person_name_masked VARCHAR(64) NOT NULL DEFAULT '',
id_number_masked VARCHAR(32) NOT NULL DEFAULT '',
id_number_hash CHAR(64) NOT NULL DEFAULT '',
company_name VARCHAR(191) NOT NULL DEFAULT '',
company_code_masked VARCHAR(32) NOT NULL DEFAULT '',
company_code_hash CHAR(64) NOT NULL DEFAULT '',
sensitive_blob LONGTEXT DEFAULT NULL,
provider_result_code VARCHAR(128) NOT NULL DEFAULT '',
provider_result_summary TEXT DEFAULT NULL,
manual_reason TEXT DEFAULT NULL,
review_note TEXT DEFAULT NULL,
reviewer_id BIGINT UNSIGNED DEFAULT NULL,
evidence_ids TEXT DEFAULT NULL,
fee_amount DECIMAL(10,2) NOT NULL DEFAULT 0,
fee_status VARCHAR(20) NOT NULL DEFAULT 'not_required',
attempt_ordinal INT UNSIGNED NOT NULL DEFAULT 0,
retry_count INT UNSIGNED NOT NULL DEFAULT 0,
created_at DATETIME NOT NULL,
provider_started_at DATETIME DEFAULT NULL,
completed_at DATETIME DEFAULT NULL,
expires_at DATETIME DEFAULT NULL,
updated_at DATETIME NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY uniq_application_uuid (application_uuid),
UNIQUE KEY uniq_user_client_request (user_id, client_request_id),
KEY idx_user_created (user_id, created_at),
KEY idx_user_type_status (user_id, type, status),
KEY idx_provider_session (provider, provider_session_id),
KEY idx_status_updated (status, updated_at),
KEY idx_id_number_hash (id_number_hash),
KEY idx_company_code_hash (company_code_hash)
) {$charset_collate};";
dbDelta($application);
$event = "CREATE TABLE {$prefix}aksrt_identity_event (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
application_id BIGINT UNSIGNED NOT NULL,
event_uuid CHAR(36) NOT NULL,
source VARCHAR(20) NOT NULL,
event_type VARCHAR(64) NOT NULL,
external_event_id VARCHAR(191) NOT NULL DEFAULT '',
dedupe_key CHAR(64) NOT NULL,
from_status VARCHAR(32) NOT NULL DEFAULT '',
to_status VARCHAR(32) NOT NULL DEFAULT '',
result_code VARCHAR(128) NOT NULL DEFAULT '',
summary_json LONGTEXT DEFAULT NULL,
actor_user_id BIGINT UNSIGNED DEFAULT NULL,
created_at DATETIME NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY uniq_event_uuid (event_uuid),
UNIQUE KEY uniq_dedupe_key (dedupe_key),
KEY idx_application_created (application_id, created_at),
KEY idx_source_external (source, external_event_id)
) {$charset_collate};";
dbDelta($event);
}
}