| 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 |
* AddObjectTimestamps class. |
| 10 |
*/ |
| 11 |
class AddObjectTimestamps 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 |
$this->add_column( |
| 27 |
$this->get_table_name(), |
| 28 |
'object_last_modified', |
| 29 |
'datetime', |
| 30 |
[ |
| 31 |
'null' => true, |
| 32 |
'default' => null, |
| 33 |
], |
| 34 |
); |
| 35 |
$this->add_column( |
| 36 |
$this->get_table_name(), |
| 37 |
'object_published_at', |
| 38 |
'datetime', |
| 39 |
[ |
| 40 |
'null' => true, |
| 41 |
'default' => null, |
| 42 |
], |
| 43 |
); |
| 44 |
$this->add_index( |
| 45 |
$this->get_table_name(), |
| 46 |
[ |
| 47 |
'object_published_at', |
| 48 |
'is_robots_noindex', |
| 49 |
'object_type', |
| 50 |
'object_sub_type', |
| 51 |
], |
| 52 |
[ |
| 53 |
'name' => 'published_sitemap_index', |
| 54 |
], |
| 55 |
); |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Migration down. |
| 60 |
* |
| 61 |
* @return void |
| 62 |
*/ |
| 63 |
public function down() { |
| 64 |
$this->remove_column( $this->get_table_name(), 'object_last_modified' ); |
| 65 |
$this->remove_column( $this->get_table_name(), 'object_published_at' ); |
| 66 |
$this->remove_index( |
| 67 |
$this->get_table_name(), |
| 68 |
[ |
| 69 |
'object_published_at', |
| 70 |
'is_robots_noindex', |
| 71 |
'object_type', |
| 72 |
'object_sub_type', |
| 73 |
], |
| 74 |
[ |
| 75 |
'name' => 'published_sitemap_index', |
| 76 |
], |
| 77 |
); |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Retrieves the table name to use for storing indexables. |
| 82 |
* |
| 83 |
* @return string The table name to use. |
| 84 |
*/ |
| 85 |
protected function get_table_name() { |
| 86 |
return Model::get_table_name( 'Indexable' ); |
| 87 |
} |
| 88 |
} |
| 89 |
|