mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-31 10:17:13 +02:00
postgres does support primary keys in the mysql format, we don't need to rewrite
This commit is contained in:
@ -77,22 +77,6 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter
|
|||||||
// Now remove handled indexes
|
// Now remove handled indexes
|
||||||
$sql = preg_replace($pattern, '', $sql);
|
$sql = preg_replace($pattern, '', $sql);
|
||||||
|
|
||||||
// Support for PRIMARY INDEX creation
|
|
||||||
$pattern = '/,\s+(PRIMARY |)KEY\s+\(((?:[\w]+(?:\([\d]+\))?[,]?)*)\)/';
|
|
||||||
if(preg_match_all($pattern, $sql, $matches, PREG_SET_ORDER)) {
|
|
||||||
foreach($matches as $match) {
|
|
||||||
$primary = $match[1];
|
|
||||||
$columns = $match[2];
|
|
||||||
$columns = preg_replace('/\(\d+\)/', '', $columns);
|
|
||||||
$index = $columns;
|
|
||||||
// Workaround for index name duplicate
|
|
||||||
$index = $table . '_' . $index;
|
|
||||||
$sql .= "\nCREATE {$primary}INDEX $index ON $table ($columns);";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Now remove handled indexes
|
|
||||||
$sql = preg_replace($pattern, '', $sql);
|
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,10 @@ final class rewriteTest extends TestCase
|
|||||||
lockout_user bigint ,
|
lockout_user bigint ,
|
||||||
lockout_username varchar(60),
|
lockout_username varchar(60),
|
||||||
lockout_active smallint NOT NULL DEFAULT 1,
|
lockout_active smallint NOT NULL DEFAULT 1,
|
||||||
lockout_context TEXT
|
lockout_context TEXT,
|
||||||
|
PRIMARY KEY (lockout_id)
|
||||||
);
|
);
|
||||||
CREATE SEQUENCE wp_itsec_lockouts_seq;
|
CREATE SEQUENCE wp_itsec_lockouts_seq;
|
||||||
CREATE PRIMARY INDEX wp_itsec_lockouts_lockout_id ON wp_itsec_lockouts (lockout_id);
|
|
||||||
SQL;
|
SQL;
|
||||||
|
|
||||||
$postgresql = pg4wp_rewrite($sql);
|
$postgresql = pg4wp_rewrite($sql);
|
||||||
|
Reference in New Issue
Block a user