You are here

public function SchemaTestExtended::testPrimaryKeyAlter in Drupal driver for SQL Server and SQL Azure 8.2

Test altering a primary key.

File

tests/src/Kernel/SchemaTestExtended.php, line 130

Class

SchemaTestExtended
Tests table creation and modification via the schema API.

Namespace

Drupal\Tests\sqlsrv\Kernel

Code

public function testPrimaryKeyAlter() {
  $table_spec = array(
    'fields' => array(
      'id' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $this->connection
    ->schema()
    ->createTable('test_table', $table_spec);
  $this
    ->assertTrue($this->connection
    ->schema()
    ->tableExists('test_table'));

  // Add a default value.
  $this->connection
    ->schema()
    ->changeField('test_table', 'id', 'id', array(
    'type' => 'int',
    'not null' => TRUE,
    'default' => 1,
  ));
}