$wpdb->prefix . 'safetybis_findings', 'ignores' => $wpdb->prefix . 'safetybis_ignores', 'refs' => $wpdb->prefix . 'safetybis_refs', ); } /** * Run install when the schema version changed (updates do not call the activation hook). */ public static function maybe_upgrade() { if ( (int) get_option( self::VERSION_OPTION ) !== self::VERSION ) { self::install(); Cron::schedule(); } } /** * Create or update tables with dbDelta. */ public static function install() { global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $t = self::tables(); $charset = $wpdb->get_charset_collate(); dbDelta( "CREATE TABLE {$t['findings']} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, scan_id varchar(32) NOT NULL, module varchar(20) NOT NULL, type varchar(30) NOT NULL, severity varchar(10) NOT NULL, item varchar(191) NOT NULL DEFAULT '', path text NOT NULL, hash char(32) NOT NULL DEFAULT '', details longtext NULL, created datetime NOT NULL, PRIMARY KEY (id), KEY module_scan (module, scan_id), KEY severity (severity) ) $charset;" ); dbDelta( "CREATE TABLE {$t['ignores']} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, module varchar(20) NOT NULL, path_key char(40) NOT NULL, path text NOT NULL, hash char(32) NOT NULL DEFAULT '', user_id bigint(20) unsigned NOT NULL DEFAULT 0, created datetime NOT NULL, PRIMARY KEY (id), UNIQUE KEY module_path (module, path_key) ) $charset;" ); dbDelta( "CREATE TABLE {$t['refs']} ( ref_key varchar(191) NOT NULL, data longtext NOT NULL, expires bigint(20) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (ref_key) ) $charset;" ); update_option( self::VERSION_OPTION, self::VERSION, false ); } }