AP_Activate::activity_table()

Description #

AnsPress activity table.

Changelog #

VersionDescription
4.1.8Added index column for activity_q_id, activity_a_id, activity_user_id.
4.1.2Introduced.

Source #

File: activate.php

	public function activity_table() {
		global $wpdb;

		$activity_exists = $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->ap_activity'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery

		// Check activity table exists.
		if ( $activity_exists === $wpdb->ap_activity ) {
			// Delete old activity table if exists.
			$existing_table = $wpdb->get_row( "SHOW COLUMNS FROM $wpdb->ap_activity LIKE 'secondary_user'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery

			if ( ! empty( $existing_table ) && 'secondary_user' === $existing_table->Field ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName
				$wpdb->query( "DROP TABLE IF EXISTS $wpdb->ap_activity" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
			}
		}

		$this->tables[] = 'CREATE TABLE ' . $wpdb->ap_activity . ' (
				activity_id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
				activity_action varchar(45) NOT NULL,
				activity_q_id bigint(20) UNSIGNED NOT NULL,
				activity_a_id bigint(20) UNSIGNED NULL,
				activity_c_id bigint(20) UNSIGNED NULL,
				activity_user_id bigint(20) UNSIGNED NOT NULL,
				activity_date timestamp NULL DEFAULT NULL,
				PRIMARY KEY  (activity_id),
				KEY activity_q_id (activity_q_id),
				KEY activity_a_id (activity_a_id),
				KEY activity_user_id (activity_user_id)
			)' . $this->charset_collate . ';';
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment