diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php index b1aa8f7..688ff79 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php @@ -421,8 +421,11 @@ function renameTable($table, $new_name) { // rename them when renaming the table. $indexes = $this->connection->query('SELECT indexname FROM pg_indexes WHERE schemaname = :schema AND tablename = :table', array(':schema' => $old_schema, ':table' => $old_table_name)); foreach ($indexes as $index) { - if (preg_match('/^' . preg_quote($old_full_name) . '_(.*)$/', $index->indexname, $matches)) { - $index_name = $matches[1]; + if (preg_match('/^' . preg_quote($old_full_name) . '__(.*)$/', $index->indexname, $matches)) { + // Remove the '__idx' suffix from index name, because + // $this->ensureIdentifiersLength() will add the __idx suffix again and + // thus would result in a wrong index name. + $index_name = substr($matches[1], 0, -5); $this->connection->query('ALTER INDEX ' . $index->indexname . ' RENAME TO ' . $this->ensureIdentifiersLength($new_name, $index_name, 'idx')); } }