prefix . 'aieo_conversion_context'; } function aieo_submission_context_install_schema() { global $wpdb; if ( ! function_exists( 'aieo_dbdelta' ) && defined( 'AIEO_DIR' ) ) { if ( file_exists( AIEO_DIR . 'includes/sql/sprocs.php' ) ) { require_once AIEO_DIR . 'includes/sql/sprocs.php'; } if ( ! function_exists( 'aieo_dbdelta' ) && file_exists( AIEO_DIR . 'includes/sql/sql-runtime-helpers.php' ) ) { require_once AIEO_DIR . 'includes/sql/sql-runtime-helpers.php'; } } $table = aieo_submission_context_table(); $charset = aieo_get_charset_collate(); $sql = "CREATE TABLE {$table} ( id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, source_key varchar(64) NOT NULL, provider varchar(20) NOT NULL DEFAULT '', entry_id bigint(20) UNSIGNED NULL DEFAULT NULL, goal_key varchar(64) NOT NULL DEFAULT '', surface varchar(64) NOT NULL DEFAULT '', page_url varchar(512) NOT NULL DEFAULT '', landing_page varchar(512) NOT NULL DEFAULT '', referrer varchar(512) NOT NULL DEFAULT '', attribution text NULL, session_ids text NULL, tracked tinyint(1) NOT NULL DEFAULT 0, email_hash char(64) NOT NULL DEFAULT '', occurred_at datetime NOT NULL, confirmed_at datetime NULL DEFAULT NULL, created_at datetime NOT NULL, PRIMARY KEY (id), UNIQUE KEY uk_source (source_key), KEY idx_entry (provider, entry_id), KEY idx_email (email_hash), KEY idx_occurred (occurred_at) ) {$charset};"; if ( function_exists( 'aieo_dbdelta' ) ) { aieo_dbdelta( $sql ); return; } require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta( $sql ); }