PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.2
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.2
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 / 20200420073606_AddColumnsToIndexables.php

20200420073606_AddColumnsToIndexables.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.2, at src/config/migrations/20200420073606_AddColumnsToIndexables.php

93 lines 2.0 KB
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
8 /**
9 * Class AddColumnsToIndexables.
10 */
11 class AddColumnsToIndexables extends Migration {
12
13 /**
14 * The plugin this migration belongs to.
15 *
16 * @var string
17 */
18 public static $plugin = 'free';
19
20 /**
21 * Migration up.
22 */
23 public function up() {
24 $tables = $this->get_tables();
25 $blog_id = \get_current_blog_id();
26 foreach ( $tables as $table ) {
27 $this->add_column(
28 $table,
29 'blog_id',
30 'biginteger',
31 [
32 'null' => false,
33 'limit' => 20,
34 'default' => $blog_id,
35 ]
36 );
37 }
38
39 $attr_limit_32 = [
40 'null' => true,
41 'limit' => 32,
42 ];
43 $attr_limit_64 = [
44 'null' => true,
45 'limit' => 64,
46 ];
47
48 $indexable_table = $this->get_indexable_table();
49 $this->add_column( $indexable_table, 'language', 'string', $attr_limit_32 );
50 $this->add_column( $indexable_table, 'region', 'string', $attr_limit_32 );
51 $this->add_column( $indexable_table, 'schema_page_type', 'string', $attr_limit_64 );
52 $this->add_column( $indexable_table, 'schema_article_type', 'string', $attr_limit_64 );
53 }
54
55 /**
56 * Migration down.
57 */
58 public function down() {
59 $tables = $this->get_tables();
60 foreach ( $tables as $table ) {
61 $this->remove_column( $table, 'blog_id' );
62 }
63
64 $indexable_table = $this->get_indexable_table();
65 $this->remove_column( $indexable_table, 'language' );
66 $this->remove_column( $indexable_table, 'region' );
67 $this->remove_column( $indexable_table, 'schema_page_type' );
68 $this->remove_column( $indexable_table, 'schema_article_type' );
69 }
70
71 /**
72 * Retrieves the Indexable table.
73 *
74 * @return string The Indexable table name.
75 */
76 protected function get_indexable_table() {
77 return Model::get_table_name( 'Indexable' );
78 }
79
80 /**
81 * Retrieves the table names to use.
82 *
83 * @return string[] The table names to use.
84 */
85 protected function get_tables() {
86 return [
87 $this->get_indexable_table(),
88 Model::get_table_name( 'Indexable_Hierarchy' ),
89 Model::get_table_name( 'Primary_Term' ),
90 ];
91 }
92 }
93