'aieo_dmm_offer_exposures', 'aieo_dmm_create_offer_responses_table' => 'aieo_dmm_offer_responses', 'aieo_dmm_create_offer_daily_table' => 'aieo_dmm_offer_daily', 'aieo_dmm_create_incentive_ledger_table' => 'aieo_dmm_incentive_ledger', ); } function aieo_dmm_create_offer_exposures_table() { global $wpdb; $table = $wpdb->prefix . 'aieo_dmm_offer_exposures'; $sql = "CREATE TABLE IF NOT EXISTS {$table} ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `person` varchar(72) NOT NULL, `offer_id` bigint(20) unsigned NOT NULL DEFAULT 0, `placement_id` bigint(20) unsigned NOT NULL DEFAULT 0, `place` varchar(16) NOT NULL DEFAULT '', `surface` varchar(40) NOT NULL DEFAULT '', `day` date NOT NULL, `first_gmt` datetime NOT NULL, `last_gmt` datetime NOT NULL, `served` int(10) unsigned NOT NULL DEFAULT 0, `in_view` int(10) unsigned NOT NULL DEFAULT 0, `engaged` int(10) unsigned NOT NULL DEFAULT 0, `set_hash` char(12) NOT NULL DEFAULT '', `source` varchar(12) NOT NULL DEFAULT '', `holdout` tinyint(1) NOT NULL DEFAULT 0, `progress` decimal(5,4) NOT NULL DEFAULT 0.0000, `last_visit` varchar(40) NOT NULL DEFAULT '', `updated_gmt` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `aieo_dmm_uq_exposure` (`person`, `offer_id`, `placement_id`, `place`, `surface`, `day`), KEY `aieo_dmm_idx_exp_offer` (`offer_id`, `day`), KEY `aieo_dmm_idx_exp_place` (`placement_id`, `day`), KEY `aieo_dmm_idx_exp_updated` (`updated_gmt`) ) " . aieo_get_charset_collate() . ';'; return false !== $wpdb->query( $sql ); } function aieo_dmm_create_offer_responses_table() { global $wpdb; $table = $wpdb->prefix . 'aieo_dmm_offer_responses'; $sql = "CREATE TABLE IF NOT EXISTS {$table} ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `person` varchar(72) NOT NULL, `offer_id` bigint(20) unsigned NOT NULL, `seq` smallint(5) unsigned NOT NULL DEFAULT 1, `offer_kind` varchar(32) NOT NULL DEFAULT '', `campaign_id` bigint(20) unsigned NOT NULL DEFAULT 0, `user_id` bigint(20) unsigned NOT NULL DEFAULT 0, `email_hash` char(64) NOT NULL DEFAULT '', `state` varchar(16) NOT NULL DEFAULT 'exposed', `state_rank` tinyint(3) unsigned NOT NULL DEFAULT 1, `progress` decimal(5,4) NOT NULL DEFAULT 0.0000, `opened_by` varchar(12) NOT NULL DEFAULT '', `opened_gmt` datetime DEFAULT NULL, `moved_gmt` datetime DEFAULT NULL, `seen_gmt` datetime DEFAULT NULL, `closed_gmt` datetime DEFAULT NULL, `closed_by` varchar(24) NOT NULL DEFAULT '', `order_id` bigint(20) unsigned NOT NULL DEFAULT 0, `visits` smallint(5) unsigned NOT NULL DEFAULT 0, `last_visit` varchar(40) NOT NULL DEFAULT '', `company` longtext DEFAULT NULL, `company_hash` char(12) NOT NULL DEFAULT '', `path` longtext DEFAULT NULL, `came_through` varchar(64) NOT NULL DEFAULT '', `assisted` longtext DEFAULT NULL, `path_v` smallint(5) unsigned NOT NULL DEFAULT 0, `holdout` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `aieo_dmm_uq_response` (`person`, `offer_id`, `seq`), KEY `aieo_dmm_idx_resp_offer` (`offer_id`, `state`, `closed_gmt`), KEY `aieo_dmm_idx_resp_open` (`closed_gmt`, `seen_gmt`), KEY `aieo_dmm_idx_resp_user` (`user_id`), KEY `aieo_dmm_idx_resp_email` (`email_hash`), KEY `aieo_dmm_idx_resp_campaign` (`campaign_id`, `closed_gmt`), KEY `aieo_dmm_idx_resp_moved` (`moved_gmt`), KEY `aieo_dmm_idx_resp_path` (`path_v`, `closed_gmt`) ) " . aieo_get_charset_collate() . ';'; return false !== $wpdb->query( $sql ); } function aieo_dmm_create_offer_daily_table() { global $wpdb; $table = $wpdb->prefix . 'aieo_dmm_offer_daily'; $sql = "CREATE TABLE IF NOT EXISTS {$table} ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `day` date NOT NULL, `grain` varchar(12) NOT NULL, `ref_id` bigint(20) unsigned NOT NULL DEFAULT 0, `taxonomy` varchar(32) NOT NULL DEFAULT '', `offer_kind` varchar(32) NOT NULL DEFAULT '', `placement_id` bigint(20) unsigned NOT NULL DEFAULT 0, `place` varchar(16) NOT NULL DEFAULT '', `surface` varchar(40) NOT NULL DEFAULT '', `served` int(10) unsigned NOT NULL DEFAULT 0, `in_view` int(10) unsigned NOT NULL DEFAULT 0, `engaged` int(10) unsigned NOT NULL DEFAULT 0, `person_days` int(10) unsigned NOT NULL DEFAULT 0, `opened` int(10) unsigned NOT NULL DEFAULT 0, `converted` int(10) unsigned NOT NULL DEFAULT 0, `declined` int(10) unsigned NOT NULL DEFAULT 0, `bought_anyway` int(10) unsigned NOT NULL DEFAULT 0, `organic` int(10) unsigned NOT NULL DEFAULT 0, `held_opened` int(10) unsigned NOT NULL DEFAULT 0, `held_bought` int(10) unsigned NOT NULL DEFAULT 0, `lines` int(10) unsigned NOT NULL DEFAULT 0, `sole_lines` int(10) unsigned NOT NULL DEFAULT 0, `applied_lines` int(10) unsigned NOT NULL DEFAULT 0, `equal_lines` int(10) unsigned NOT NULL DEFAULT 0, `outbid_lines` int(10) unsigned NOT NULL DEFAULT 0, `blocked_lines` int(10) unsigned NOT NULL DEFAULT 0, `qualify_lines` int(10) unsigned NOT NULL DEFAULT 0, `list_value` decimal(19,4) NOT NULL DEFAULT 0.0000, `reduction` decimal(19,4) NOT NULL DEFAULT 0.0000, `alone` decimal(19,4) NOT NULL DEFAULT 0.0000, `marginal` decimal(19,4) NOT NULL DEFAULT 0.0000, `cost_goods` decimal(19,4) NOT NULL DEFAULT 0.0000, `margin_left` decimal(19,4) NOT NULL DEFAULT 0.0000, `own_units` int(10) unsigned NOT NULL DEFAULT 0, `own_revenue` decimal(19,4) NOT NULL DEFAULT 0.0000, `orders` int(10) unsigned NOT NULL DEFAULT 0, `orders_revenue` decimal(19,4) NOT NULL DEFAULT 0.0000, `built_v` smallint(5) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `aieo_dmm_uq_daily` (`grain`, `ref_id`, `taxonomy`, `offer_kind`, `placement_id`, `place`, `surface`, `day`), KEY `aieo_dmm_idx_daily_day` (`day`) ) " . aieo_get_charset_collate() . ';'; return false !== $wpdb->query( $sql ); } function aieo_dmm_create_incentive_ledger_table() { global $wpdb; $table = $wpdb->prefix . 'aieo_dmm_incentive_ledger'; $sql = "CREATE TABLE IF NOT EXISTS {$table} ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `person` varchar(72) NOT NULL, `user_id` bigint(20) unsigned NOT NULL DEFAULT 0, `email_hash` char(64) NOT NULL DEFAULT '', `counter` varchar(32) NOT NULL, `delta` int(11) NOT NULL DEFAULT 0, `value` decimal(19,4) NOT NULL DEFAULT 0.0000, `order_id` bigint(20) unsigned NOT NULL DEFAULT 0, `order_item_id` bigint(20) unsigned NOT NULL DEFAULT 0, `offer_id` bigint(20) unsigned NOT NULL DEFAULT 0, `product_id` bigint(20) unsigned NOT NULL DEFAULT 0, `source` varchar(12) NOT NULL DEFAULT '', `event_key` varchar(64) NOT NULL, `created_gmt` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `aieo_dmm_uq_incentive` (`person`, `event_key`), KEY `aieo_dmm_idx_inc_user` (`user_id`, `counter`), KEY `aieo_dmm_idx_inc_email` (`email_hash`, `counter`), KEY `aieo_dmm_idx_inc_order` (`order_id`), KEY `aieo_dmm_idx_inc_created` (`created_gmt`) ) " . aieo_get_charset_collate() . ';'; return false !== $wpdb->query( $sql ); } }