postgres does support primary keys in the mysql format, we don't need to rewrite

This commit is contained in:
Matthew Bucci
2023-11-26 01:42:21 -08:00
parent 91f1612d10
commit cbd3d83918
2 changed files with 2 additions and 18 deletions

View File

@ -77,22 +77,6 @@ class CreateTableSQLRewriter extends AbstractSQLRewriter
// Now remove handled indexes
$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;
}
}

View File

@ -63,10 +63,10 @@ final class rewriteTest extends TestCase
lockout_user bigint ,
lockout_username varchar(60),
lockout_active smallint NOT NULL DEFAULT 1,
lockout_context TEXT
lockout_context TEXT,
PRIMARY KEY (lockout_id)
);
CREATE SEQUENCE wp_itsec_lockouts_seq;
CREATE PRIMARY INDEX wp_itsec_lockouts_lockout_id ON wp_itsec_lockouts (lockout_id);
SQL;
$postgresql = pg4wp_rewrite($sql);