<?php
/**
 * Journey Events Table.
 *
 * @package     EDD\Pro\CartRecovery\Database\Tables
 * @copyright   Copyright (c) 2026 Sandhills Development, LLC
 * @license     https://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       3.6.5
 */

namespace EDD\Pro\CartRecovery\Database\Tables;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

use EDD\Database\Table;

/**
 * Registers the edd_acr_journey_events database table.
 */
final class JourneyEvents extends Table {

	/**
	 * Table name (without prefix).
	 *
	 * @var string
	 */
	protected $name = 'acr_journey_events';

	/**
	 * Database version.
	 *
	 * @var int
	 */
	protected $version = 202602030;

	/**
	 * Upgrade routines.
	 *
	 * @var array
	 */
	protected $upgrades = array();

	/**
	 * Set the table schema.
	 */
	protected function set_schema() {
		$this->schema = 'id bigint(20) unsigned NOT NULL auto_increment,
			cart_id bigint(20) unsigned NOT NULL,
			email_id bigint(20) unsigned default NULL,
			event_type varchar(50) NOT NULL,
			event_data longtext default NULL,
			user_agent varchar(255) default NULL,
			ip_address varchar(45) default NULL,
			date_created datetime NOT NULL default CURRENT_TIMESTAMP,
			PRIMARY KEY (id),
			KEY cart_id (cart_id),
			KEY email_id (email_id),
			KEY event_type (event_type),
			KEY date_created (date_created),
			KEY idx_cart_event (cart_id, event_type),
			KEY idx_cart_date (cart_id, date_created)
		';
	}
}
