mirror of
git://develop.git.wordpress.org/
synced 2025-03-14 17:09:47 +01:00
Upgrades: Add support for FULLTEXT
indexes to dbDelta()
.
Props edirect24, mdawaffe, pento. Fixes #14445. git-svn-id: https://develop.svn.wordpress.org/trunk@35487 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3ef1e8194b
commit
c9f7e05f7b
@ -2195,6 +2195,7 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
$keyname = $tableindex->Key_name;
|
||||
$index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
|
||||
$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
|
||||
$index_ary[$keyname]['index_type'] = $tableindex->Index_type;
|
||||
}
|
||||
|
||||
// For each actual index in the index array.
|
||||
@ -2207,6 +2208,9 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
} elseif ( $index_data['unique'] ) {
|
||||
$index_string .= 'UNIQUE ';
|
||||
}
|
||||
if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) {
|
||||
$index_string .= 'FULLTEXT ';
|
||||
}
|
||||
$index_string .= 'KEY ';
|
||||
if ($index_name != 'PRIMARY') {
|
||||
$index_string .= $index_name;
|
||||
|
@ -25,6 +25,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// Forcing MyISAM, because InnoDB only started supporting FULLTEXT indexes in MySQL 5.7.
|
||||
$wpdb->query(
|
||||
"
|
||||
CREATE TABLE {$wpdb->prefix}dbdelta_test (
|
||||
@ -32,8 +33,9 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
column_1 varchar(255) NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY key_1 (column_1),
|
||||
KEY compoud_key (id,column_1)
|
||||
)
|
||||
KEY compoud_key (id,column_1),
|
||||
FULLTEXT KEY fulltext_key (column_1)
|
||||
) ENGINE=MyISAM
|
||||
"
|
||||
);
|
||||
|
||||
@ -248,7 +250,30 @@ class Tests_dbDelta extends WP_UnitTestCase {
|
||||
$this->assertTableRowHasValue( 'column_1', 'wcphilly2015', $wpdb->prefix . 'dbdelta_test' );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test that FULLTEXT indexes are detected.
|
||||
* @ticket 14445
|
||||
*/
|
||||
public function test_fulltext_index() {
|
||||
global $wpdb;
|
||||
|
||||
$updates = dbDelta(
|
||||
"
|
||||
CREATE TABLE {$wpdb->prefix}dbdelta_test (
|
||||
id bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
column_1 varchar(255) NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY key_1 (column_1),
|
||||
KEY compoud_key (id,column_1),
|
||||
FULLTEXT KEY fulltext_key (column_1)
|
||||
)
|
||||
", false
|
||||
);
|
||||
|
||||
$this->assertEmpty( $updates );
|
||||
}
|
||||
|
||||
//
|
||||
// Assertions.
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user