Merged in feature/from-pantheon (pull request #16)

code from pantheon

* code from pantheon
This commit is contained in:
Tony Volpe
2024-01-10 17:03:02 +00:00
parent 054b4fffc9
commit 4eb982d7a8
16492 changed files with 3475854 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
<?php
namespace Yoast\WP\SEO\Config\Migrations;
use Yoast\WP\Lib\Migrations\Migration;
use Yoast\WP\Lib\Model;
/**
* Class WpYoastPremiumImprovedInternalLinking
*
* @package Yoast\WP\SEO\Config\Migrations
*/
class WpYoastPremiumImprovedInternalLinking extends Migration {
/**
* The plugin this migration belongs to.
*
* @var string
*/
public static $plugin = 'premium';
/**
* Migration up.
*/
public function up() {
$table_name = $this->get_table_name();
$adapter = $this->get_adapter();
if ( ! $adapter->has_table( $table_name ) ) {
$table = $this->create_table( $table_name );
$table->column(
'stem',
'string',
[
'null' => true,
'limit' => 191,
]
);
$table->column(
'indexable_id',
'integer',
[
'unsigned' => true,
'null' => true,
'limit' => 11,
]
);
$table->column( 'weight', 'float' );
$table->finish();
}
if ( ! $adapter->has_index( $table_name, 'stem', [ 'name' => 'stem' ] ) ) {
$this->add_index(
$table_name,
[
'stem',
],
[
'name' => 'stem',
]
);
}
if ( ! $adapter->has_index( $table_name, 'indexable_id', [ 'name' => 'indexable_id' ] ) ) {
$this->add_index(
$table_name,
[
'indexable_id',
],
[
'name' => 'indexable_id',
]
);
}
}
/**
* Migration down.
*/
public function down() {
$table_name = $this->get_table_name();
if ( $this->get_adapter()->has_table( $table_name ) ) {
$this->drop_table( $table_name );
}
}
/**
* Retrieves the table name to use.
*
* @return string The table name to use.
*/
protected function get_table_name() {
return Model::get_table_name( 'Prominent_Words' );
}
}

View File

@@ -0,0 +1,85 @@
<?php
namespace Yoast\WP\SEO\Premium\Config\Migrations;
use Yoast\WP\Lib\Migrations\Migration;
use Yoast\WP\Lib\Model;
/**
* AddIndexOnIndexableIdAndStem class.
*/
class AddIndexOnIndexableIdAndStem extends Migration {
/**
* The plugin this migration belongs to.
*
* @var string
*/
public static $plugin = 'premium';
/**
* The columns on which an index should be added.
*
* @var string[]
*/
protected $columns_with_index = [
'indexable_id',
'stem',
];
/**
* Migration up. Adds a combined index on 'indexable_id' and 'stem'.
*
* @return void
*/
public function up() {
$table_name = $this->get_table_name();
$adapter = $this->get_adapter();
if ( ! $adapter->has_table( $table_name ) ) {
return;
}
// Create the index if it doesn't exist already.
if ( ! $adapter->has_index( $table_name, $this->columns_with_index, [ 'name' => 'indexable_id_and_stem' ] ) ) {
$this->add_index(
$this->get_table_name(),
$this->columns_with_index,
[ 'name' => 'indexable_id_and_stem' ]
);
}
}
/**
* Migration down. Removes the combined index on 'indexable_id' and 'stem'.
*
* @return void
*/
public function down() {
$table_name = $this->get_table_name();
$adapter = $this->get_adapter();
if ( ! $adapter->has_table( $table_name ) ) {
return;
}
// Remove the index if it exists.
if ( $adapter->has_index( $table_name, $this->columns_with_index, [ 'name' => 'indexable_id_and_stem' ] ) ) {
$this->remove_index(
$this->get_table_name(),
$this->columns_with_index,
[ 'name' => 'indexable_id_and_stem' ]
);
}
}
/**
* Retrieves the table name to use for storing prominent words.
*
* @return string The table name to use.
*/
protected function get_table_name() {
return Model::get_table_name( 'Prominent_Words' );
}
}