prefix . self::TABLE; } /** * Schema step 2: the unique key gained the changed-field column (one image warning per image slot of a row). * * @return void */ public static function upgradeTo2(): void { global $wpdb; $table = self::table(); $old = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = %s AND INDEX_NAME = %s', $table, 'job_row_code' ) ); if ( (int) $old > 0 ) { $wpdb->query( $wpdb->prepare( 'ALTER TABLE %i DROP INDEX job_row_code', $table ) ); } } /** * Create or upgrade the table. * * @return void */ public static function install(): void { global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $table = self::table(); $charset = $wpdb->get_charset_collate(); dbDelta( "CREATE TABLE {$table} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, job_id bigint(20) unsigned NOT NULL, row_no int(10) unsigned NOT NULL, byte_offset bigint(20) unsigned NOT NULL DEFAULT 0, status varchar(10) NOT NULL, code varchar(40) NOT NULL DEFAULT '', message varchar(255) NOT NULL DEFAULT '', product_id bigint(20) unsigned NOT NULL DEFAULT 0, fields varchar(190) NOT NULL DEFAULT '', diff longtext NULL, resolved_by bigint(20) unsigned NOT NULL DEFAULT 0, created_at datetime NOT NULL, PRIMARY KEY (id), UNIQUE KEY job_row_key (job_id,row_no,status,code,fields), KEY job_status_row (job_id,status,row_no), KEY product (product_id), KEY created (created_at) ) {$charset}" ); } }