PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.6
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / config / migrations / 20200609154515_AddHasAncestorsColumn.php

20200609154515_AddHasAncestorsColumn.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.6, at src/config/migrations/20200609154515_AddHasAncestorsColumn.php

50 lines 903 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Config\Migrations;
4
5 use Yoast\WP\Lib\Migrations\Migration;
6 use Yoast\WP\Lib\Model;
7 use Yoast\WP\SEO\WordPress\Wrapper;
8
9 /**
10 * Class AddHasAncestorsColumn.
11 */
12 class AddHasAncestorsColumn extends Migration {
13
14 /**
15 * The plugin this migration belongs to.
16 *
17 * @var string
18 */
19 public static $plugin = 'free';
20
21 /**
22 * Migration up.
23 */
24 public function up() {
25 $this->add_column(
26 Model::get_table_name( 'Indexable' ),
27 'has_ancestors',
28 'boolean',
29 [
30 'default' => false,
31 ]
32 );
33
34 Wrapper::get_wpdb()->query(
35 '
36 UPDATE ' . Model::get_table_name( 'Indexable' ) . '
37 SET has_ancestors = 1
38 WHERE id IN ( SELECT indexable_id FROM ' . Model::get_table_name( 'Indexable_Hierarchy' ) . ' )
39 '
40 );
41 }
42
43 /**
44 * Migration down.
45 */
46 public function down() {
47 $this->remove_column( Model::get_table_name( 'Indexable' ), 'has_ancestors' );
48 }
49 }
50