Tests renaming a table where the new index name is equal to the table name.

File

core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php, line 344

Class

SchemaTest
Tests schema API for the PostgreSQL driver.

Namespace

Drupal\Tests\pgsql\Kernel\pgsql

Code

public function testRenameTableWithNewIndexNameEqualsTableName() {

  // Special table names for colliding with the PostgreSQL new index name.
  $table_name_old = 'some_new_table_name__id__idx';
  $table_name_new = 'some_new_table_name';
  $table_specification = [
    'fields' => [
      'id' => [
        'type' => 'int',
        'default' => NULL,
      ],
    ],
    'indexes' => [
      'id' => [
        'id',
      ],
    ],
  ];
  $this->schema
    ->createTable($table_name_old, $table_specification);

  // Renaming the table can fail for PostgreSQL, when a new index name is
  // equal to the old table name.
  $this->schema
    ->renameTable($table_name_old, $table_name_new);
  $this
    ->assertTrue($this->schema
    ->tableExists($table_name_new));
}