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