# defender-security/6.2.0/src/traits/pro-database-tables.php

Defender Security – Malware Scanner, Login Security &amp; Firewall, version 6.2.0. 46 lines.

- Page: https://pluginprobe.com/plugins/defender-security/6.2.0/code/src/traits/pro-database-tables.php
- Raw: https://pluginprobe.com/plugins/defender-security/6.2.0/raw/src/traits/pro-database-tables.php
- Modified: 2026-08-24T08:37:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/defender-security/6.2.0/code/src/traits/pro-database-tables.php#L10-L20`.

```php
<?php
/**
 * Pro-only database table creation methods.
 *
 * @package WP_Defender\Traits
 */

namespace WP_Defender\Traits;

/**
 * Provides database table creation for Pro-only features (Audit Logging).
 */
trait Pro_Database_Tables {

	/**
	 * Creates the audit log table used for caching audit events.
	 */
	protected function create_table_audit_log(): void {
		global $wpdb;

		$charset_collate = $wpdb->get_charset_collate();
		// Audit log table. Though our data mainly store on API side, we will need a table for caching.
		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->base_prefix}defender_audit_log (
 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `timestamp` int NOT NULL,
 `event_type` varchar(255) NOT NULL,
 `action_type` varchar(255) NOT NULL,
 `site_url` varchar(255) NOT NULL,
 `user_id` int NOT NULL,
 `context` varchar(255) NOT NULL,
 `ip` varchar(45) NOT NULL,
 `msg` varchar(255) NOT NULL,
 `blog_id` int NOT NULL,
 `synced` int NOT NULL,
 `ttl` int NOT NULL,
 PRIMARY KEY  (`id`),
 KEY `event_type` (`event_type`),
 KEY `action_type` (`action_type`),
 KEY `user_id` (`user_id`),
 KEY `context` (`context`),
 KEY `ip` (`ip`)
) $charset_collate;";
		$wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
	}
}

```
