<?php
/**
 * Create Points Table Migration.
 *
 * @package Ugcify
 */

namespace Ugcify\Database\Migrations;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * CreatePointsTable migration class.
 */
class CreatePointsTable {

	/**
	 * WordPress database instance.
	 *
	 * @var \wpdb
	 */
	private $wpdb;

	/**
	 * Constructor.
	 *
	 * @param \wpdb $wpdb WordPress database instance.
	 */
	public function __construct( $wpdb ) {
		$this->wpdb = $wpdb;
	}

	/**
	 * Run migration.
	 *
	 * @return string SQL statement.
	 */
	public function run() {
		$table_name      = $this->wpdb->prefix . 'ugcify_points';
		$charset_collate = $this->wpdb->get_charset_collate();

		return "CREATE TABLE $table_name (
			id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
			user_id BIGINT(20) UNSIGNED NOT NULL,
			review_id BIGINT(20) UNSIGNED,
			points INT(11) NOT NULL,
			created_at DATETIME NOT NULL,
			PRIMARY KEY (id),
			KEY user_id (user_id),
			KEY review_id (review_id)
		) $charset_collate;";
	}
}
