Migration.php
1 year ago
Migration_10.php
2 years ago
Migration_11.php
2 years ago
Migration_12.php
1 year ago
Migration_13.php
2 years ago
Migration_14.php
2 years ago
Migration_15.php
2 years ago
Migration_16.php
2 years ago
Migration_17.php
1 year ago
Migration_18.php
2 years ago
Migration_19.php
2 years ago
Migration_1_0.php
2 years ago
Migration_1_6.php
2 years ago
Migration_1_8.php
2 years ago
Migration_1_9.php
2 years ago
Migration_2.php
2 years ago
Migration_20.php
2 years ago
Migration_21.php
2 years ago
Migration_22.php
2 years ago
Migration_23.php
2 years ago
Migration_24.php
2 years ago
Migration_25.php
2 years ago
Migration_26.php
2 years ago
Migration_27.php
2 years ago
Migration_28.php
2 years ago
Migration_29.php
2 years ago
Migration_3.php
2 years ago
Migration_30.php
2 years ago
Migration_31.php
2 years ago
Migration_32.php
2 years ago
Migration_33.php
2 years ago
Migration_34.php
1 year ago
Migration_35.php
1 year ago
Migration_36.php
1 year ago
Migration_4.php
2 years ago
Migration_5.php
2 years ago
Migration_6.php
2 years ago
Migration_7.php
1 year ago
Migration_8.php
2 years ago
Migration_9.php
2 years ago
Migration_Job.php
2 years ago
Migrations.php
1 year ago
Step_Migration.php
1 year ago
Migration_28.php
41 lines
| 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 |