PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.7
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.7
28.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 All 130 releases
wordpress-seo / src / config / migrations / 20171228151841_WpYoastPrimaryTerm.php

20171228151841_WpYoastPrimaryTerm.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.7, at src/config/migrations/20171228151841_WpYoastPrimaryTerm.php

103 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 Yoast\WP\SEO\Config\Migrations;
4
5 use Yoast\WP\Lib\Migrations\Migration;
6 use Yoast\WP\Lib\Model;
7
8 /**
9 * Migration for the Primary Term.
10 */
11 class WpYoastPrimaryTerm 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 * @return void
24 */
25 public function up() {
26 $table_name = $this->get_table_name();
27
28 $indexable_table = $this->create_table( $table_name );
29
30 $indexable_table->column(
31 'post_id',
32 'integer',
33 [
34 'unsigned' => true,
35 'null' => false,
36 'limit' => 11,
37 ],
38 );
39 $indexable_table->column(
40 'term_id',
41 'integer',
42 [
43 'unsigned' => true,
44 'null' => false,
45 'limit' => 11,
46 ],
47 );
48 $indexable_table->column(
49 'taxonomy',
50 'string',
51 [
52 'null' => false,
53 'limit' => 32,
54 ],
55 );
56
57 // Executes the SQL to create the table.
58 $indexable_table->finish();
59
60 $this->add_index(
61 $table_name,
62 [
63 'post_id',
64 'taxonomy',
65 ],
66 [
67 'name' => 'post_taxonomy',
68 ],
69 );
70
71 $this->add_index(
72 $table_name,
73 [
74 'post_id',
75 'term_id',
76 ],
77 [
78 'name' => 'post_term',
79 ],
80 );
81
82 $this->add_timestamps( $table_name );
83 }
84
85 /**
86 * Migration down.
87 *
88 * @return void
89 */
90 public function down() {
91 $this->drop_table( $this->get_table_name() );
92 }
93
94 /**
95 * Retrieves the table name to use.
96 *
97 * @return string Table name to use.
98 */
99 protected function get_table_name() {
100 return Model::get_table_name( 'Primary_Term' );
101 }
102 }
103