PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.5
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 27.5, at src/config/migrations/20200609154515_AddHasAncestorsColumn.php

54 lines 947 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 * @return void
25 */
26 public function up() {
27 $this->add_column(
28 Model::get_table_name( 'Indexable' ),
29 'has_ancestors',
30 'boolean',
31 [
32 'default' => false,
33 ],
34 );
35
36 Wrapper::get_wpdb()->query(
37 '
38 UPDATE ' . Model::get_table_name( 'Indexable' ) . '
39 SET has_ancestors = 1
40 WHERE id IN ( SELECT indexable_id FROM ' . Model::get_table_name( 'Indexable_Hierarchy' ) . ' )
41 ',
42 );
43 }
44
45 /**
46 * Migration down.
47 *
48 * @return void
49 */
50 public function down() {
51 $this->remove_column( Model::get_table_name( 'Indexable' ), 'has_ancestors' );
52 }
53 }
54