PluginProbe
Independent Analytics – WordPress Analytics Plugin / 2.4.2
Independent Analytics – WordPress Analytics Plugin v2.4.2
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 All 120 releases
independent-analytics / IAWP / Migrations / Migration_28.php
Migration_28.php
41 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IAWP\Migrations;
4
5 use IAWP\Query;
6 /** @internal */
7 class Migration_28 extends \IAWP\Migrations\Step_Migration
8 {
9 /**
10 * @return int
11 */
12 protected function database_version() : int
13 {
14 return 28;
15 }
16 /**
17 * @return array
18 */
19 protected function queries() : array
20 {
21 return [$this->add_initial_view_id_column(), $this->populate_column(), $this->index_column()];
22 }
23 private function add_initial_view_id_column() : string
24 {
25 $wc_orders_table = Query::get_table_name(Query::WC_ORDERS);
26 return "\n ALTER TABLE {$wc_orders_table} ADD COLUMN initial_view_id BIGINT(20) UNSIGNED AFTER view_id;\n ";
27 }
28 private function populate_column() : string
29 {
30 $views_table = Query::get_table_name(Query::VIEWS);
31 $sessions_table = Query::get_table_name(Query::SESSIONS);
32 $wc_orders_table = Query::get_table_name(Query::WC_ORDERS);
33 return "\n UPDATE {$wc_orders_table} AS orders\n JOIN {$views_table} AS views ON orders.view_id = views.id\n JOIN {$sessions_table} AS sessions on views.session_id = sessions.session_id\n SET orders.initial_view_id = sessions.initial_view_id\n ";
34 }
35 private function index_column() : string
36 {
37 $wc_orders_table = Query::get_table_name(Query::WC_ORDERS);
38 return "\n CREATE INDEX initial_view_id ON {$wc_orders_table} (initial_view_id)\n ";
39 }
40 }
41