Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../lib/migratio...
File: migration.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\Lib\Migrations;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Base migration class.
[5] Fix | Delete
*/
[6] Fix | Delete
abstract class Migration {
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* The plugin this migration belongs to.
[10] Fix | Delete
*
[11] Fix | Delete
* @var string
[12] Fix | Delete
*/
[13] Fix | Delete
public static $plugin = 'unknown';
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* The adapter.
[17] Fix | Delete
*
[18] Fix | Delete
* @var Adapter
[19] Fix | Delete
*/
[20] Fix | Delete
private $adapter;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Performs the migration.
[24] Fix | Delete
*
[25] Fix | Delete
* @return void
[26] Fix | Delete
*/
[27] Fix | Delete
abstract public function up();
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Reverts the migration.
[31] Fix | Delete
*
[32] Fix | Delete
* @return void
[33] Fix | Delete
*/
[34] Fix | Delete
abstract public function down();
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Creates a new migration.
[38] Fix | Delete
*
[39] Fix | Delete
* @param Adapter $adapter The current adapter.
[40] Fix | Delete
*/
[41] Fix | Delete
public function __construct( Adapter $adapter ) {
[42] Fix | Delete
$this->set_adapter( $adapter );
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Sets an adapter.
[47] Fix | Delete
*
[48] Fix | Delete
* @param Adapter $adapter The adapter to set.
[49] Fix | Delete
*
[50] Fix | Delete
* @return $this|null
[51] Fix | Delete
*/
[52] Fix | Delete
public function set_adapter( $adapter ) {
[53] Fix | Delete
if ( ! $adapter instanceof Adapter ) {
[54] Fix | Delete
return;
[55] Fix | Delete
}
[56] Fix | Delete
$this->adapter = $adapter;
[57] Fix | Delete
return $this;
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Returns the current adapter.
[62] Fix | Delete
*
[63] Fix | Delete
* @return object
[64] Fix | Delete
*/
[65] Fix | Delete
public function get_adapter() {
[66] Fix | Delete
return $this->adapter;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* Creates a database.
[71] Fix | Delete
*
[72] Fix | Delete
* @param string $name The name of the database.
[73] Fix | Delete
* @param array|null $options The options.
[74] Fix | Delete
*
[75] Fix | Delete
* @return bool
[76] Fix | Delete
*/
[77] Fix | Delete
public function create_database( $name, $options = null ) {
[78] Fix | Delete
return $this->adapter->create_database( $name, $options );
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Drops a database.
[83] Fix | Delete
*
[84] Fix | Delete
* @param string $name The name of the database.
[85] Fix | Delete
*
[86] Fix | Delete
* @return bool
[87] Fix | Delete
*/
[88] Fix | Delete
public function drop_database( $name ) {
[89] Fix | Delete
return $this->adapter->drop_database( $name );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Drops a table.
[94] Fix | Delete
*
[95] Fix | Delete
* @param string $table_name The name of the table.
[96] Fix | Delete
*
[97] Fix | Delete
* @return bool
[98] Fix | Delete
*/
[99] Fix | Delete
public function drop_table( $table_name ) {
[100] Fix | Delete
return $this->adapter->drop_table( $table_name );
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Renames a table.
[105] Fix | Delete
*
[106] Fix | Delete
* @param string $name The name of the table.
[107] Fix | Delete
* @param string $new_name The new name of the table.
[108] Fix | Delete
*
[109] Fix | Delete
* @return bool
[110] Fix | Delete
*/
[111] Fix | Delete
public function rename_table( $name, $new_name ) {
[112] Fix | Delete
return $this->adapter->rename_table( $name, $new_name );
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
/**
[116] Fix | Delete
* Renames a column.
[117] Fix | Delete
*
[118] Fix | Delete
* @param string $table_name The name of the table.
[119] Fix | Delete
* @param string $column_name The column name.
[120] Fix | Delete
* @param string $new_column_name The new column name.
[121] Fix | Delete
*
[122] Fix | Delete
* @return bool
[123] Fix | Delete
*/
[124] Fix | Delete
public function rename_column( $table_name, $column_name, $new_column_name ) {
[125] Fix | Delete
return $this->adapter->rename_column( $table_name, $column_name, $new_column_name );
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
/**
[129] Fix | Delete
* Adds a column.
[130] Fix | Delete
*
[131] Fix | Delete
* @param string $table_name The name of the table.
[132] Fix | Delete
* @param string $column_name The column name.
[133] Fix | Delete
* @param string $type The column type.
[134] Fix | Delete
* @param array|string $options The options.
[135] Fix | Delete
*
[136] Fix | Delete
* @return bool
[137] Fix | Delete
*/
[138] Fix | Delete
public function add_column( $table_name, $column_name, $type, $options = [] ) {
[139] Fix | Delete
return $this->adapter->add_column( $table_name, $column_name, $type, $options );
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
/**
[143] Fix | Delete
* Removes a column.
[144] Fix | Delete
*
[145] Fix | Delete
* @param string $table_name The name of the table.
[146] Fix | Delete
* @param string $column_name The column name.
[147] Fix | Delete
*
[148] Fix | Delete
* @return bool
[149] Fix | Delete
*/
[150] Fix | Delete
public function remove_column( $table_name, $column_name ) {
[151] Fix | Delete
return $this->adapter->remove_column( $table_name, $column_name );
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
/**
[155] Fix | Delete
* Changes a column.
[156] Fix | Delete
*
[157] Fix | Delete
* @param string $table_name The name of the table.
[158] Fix | Delete
* @param string $column_name The column name.
[159] Fix | Delete
* @param string $type The column type.
[160] Fix | Delete
* @param array|string $options The options.
[161] Fix | Delete
*
[162] Fix | Delete
* @return bool
[163] Fix | Delete
*/
[164] Fix | Delete
public function change_column( $table_name, $column_name, $type, $options = [] ) {
[165] Fix | Delete
return $this->adapter->change_column( $table_name, $column_name, $type, $options );
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
/**
[169] Fix | Delete
* Adds an index.
[170] Fix | Delete
*
[171] Fix | Delete
* @param string $table_name The name of the table.
[172] Fix | Delete
* @param array|string $column_name The column name.
[173] Fix | Delete
* @param array|string $options The options.
[174] Fix | Delete
*
[175] Fix | Delete
* @return bool
[176] Fix | Delete
*/
[177] Fix | Delete
public function add_index( $table_name, $column_name, $options = [] ) {
[178] Fix | Delete
return $this->adapter->add_index( $table_name, $column_name, $options );
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
/**
[182] Fix | Delete
* Removes an index.
[183] Fix | Delete
*
[184] Fix | Delete
* @param string $table_name The name of the table.
[185] Fix | Delete
* @param array|string $column_name The column name.
[186] Fix | Delete
* @param array|string $options The options.
[187] Fix | Delete
*
[188] Fix | Delete
* @return bool
[189] Fix | Delete
*/
[190] Fix | Delete
public function remove_index( $table_name, $column_name, $options = [] ) {
[191] Fix | Delete
return $this->adapter->remove_index( $table_name, $column_name, $options );
[192] Fix | Delete
}
[193] Fix | Delete
[194] Fix | Delete
/**
[195] Fix | Delete
* Adds timestamps.
[196] Fix | Delete
*
[197] Fix | Delete
* @param string $table_name The name of the table.
[198] Fix | Delete
* @param string $created_column_name Created at column name.
[199] Fix | Delete
* @param string $updated_column_name Updated at column name.
[200] Fix | Delete
*
[201] Fix | Delete
* @return bool
[202] Fix | Delete
*/
[203] Fix | Delete
public function add_timestamps( $table_name, $created_column_name = 'created_at', $updated_column_name = 'updated_at' ) {
[204] Fix | Delete
return $this->adapter->add_timestamps( $table_name, $created_column_name, $updated_column_name );
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
/**
[208] Fix | Delete
* Removes timestamps.
[209] Fix | Delete
*
[210] Fix | Delete
* @param string $table_name The name of the table.
[211] Fix | Delete
* @param string $created_column_name Created at column name.
[212] Fix | Delete
* @param string $updated_column_name Updated at column name.
[213] Fix | Delete
*
[214] Fix | Delete
* @return bool
[215] Fix | Delete
*/
[216] Fix | Delete
public function remove_timestamps( $table_name, $created_column_name = 'created_at', $updated_column_name = 'updated_at' ) {
[217] Fix | Delete
return $this->adapter->remove_timestamps( $table_name, $created_column_name, $updated_column_name );
[218] Fix | Delete
}
[219] Fix | Delete
[220] Fix | Delete
/**
[221] Fix | Delete
* Creates a table.
[222] Fix | Delete
*
[223] Fix | Delete
* @param string $table_name The name of the table.
[224] Fix | Delete
* @param array|string $options The options.
[225] Fix | Delete
*
[226] Fix | Delete
* @return bool|Table
[227] Fix | Delete
*/
[228] Fix | Delete
public function create_table( $table_name, $options = [] ) {
[229] Fix | Delete
return $this->adapter->create_table( $table_name, $options );
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
/**
[233] Fix | Delete
* Execute a query and return the first result.
[234] Fix | Delete
*
[235] Fix | Delete
* @param string $sql The query to run.
[236] Fix | Delete
*
[237] Fix | Delete
* @return array
[238] Fix | Delete
*/
[239] Fix | Delete
public function select_one( $sql ) {
[240] Fix | Delete
return $this->adapter->select_one( $sql );
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
/**
[244] Fix | Delete
* Execute a query and return all results.
[245] Fix | Delete
*
[246] Fix | Delete
* @param string $sql The query to run.
[247] Fix | Delete
*
[248] Fix | Delete
* @return array
[249] Fix | Delete
*/
[250] Fix | Delete
public function select_all( $sql ) {
[251] Fix | Delete
return $this->adapter->select_all( $sql );
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
/**
[255] Fix | Delete
* Execute a query.
[256] Fix | Delete
*
[257] Fix | Delete
* @param string $sql The query to run.
[258] Fix | Delete
*
[259] Fix | Delete
* @return bool
[260] Fix | Delete
*/
[261] Fix | Delete
public function query( $sql ) {
[262] Fix | Delete
return $this->adapter->query( $sql );
[263] Fix | Delete
}
[264] Fix | Delete
[265] Fix | Delete
/**
[266] Fix | Delete
* Returns a quoted string.
[267] Fix | Delete
*
[268] Fix | Delete
* @param string $str The string to quote.
[269] Fix | Delete
*
[270] Fix | Delete
* @return string
[271] Fix | Delete
*/
[272] Fix | Delete
public function quote_string( $str ) {
[273] Fix | Delete
return $this->adapter->quote_string( $str );
[274] Fix | Delete
}
[275] Fix | Delete
}
[276] Fix | Delete
[277] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function