Skip to content

Commit

Permalink
Some codereview changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SCIF committed Jan 16, 2018
1 parent c81ef0f commit 1a0614b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ public function getDropForeignKeySQL($foreignKey, $table)

protected function getDropPrimaryKeySQL(string $table) : string
{
return $this->getDropConstraintSQL("{$table}_pkey", $table);
return $this->getDropConstraintSQL($table . '_pkey', $table);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,34 +502,6 @@ public function autoIncrementTypeMigrations() : array
'bigint->int' => ['bigint', 'integer', 'INT'],
];
}

/**
* @group 2925
*/
public function testAlterTableChangePrimaryKey() : void
{
$tableFrom = new Table('primary_key_userid');
$column = $tableFrom->addColumn('user_id', 'integer');
$column->setAutoincrement(true);
$tableFrom->setPrimaryKey(['user_id']);
$this->_sm->dropAndCreateTable($tableFrom);

$tableFrom = $this->_sm->listTableDetails('primary_key_userid');
self::assertTrue($tableFrom->getColumn('user_id')->getAutoincrement());

$tableTo = new Table('primary_key_id');
$column = $tableTo->addColumn('id', 'integer');
$column->setAutoincrement(true);
$tableTo->setPrimaryKey(['id']);

$c = new Comparator();
$diff = $c->diffTable($tableFrom, $tableTo);
self::assertInstanceOf(TableDiff::class, $diff, "There should be a difference and not false being returned from the table comparison");

$this->_sm->alterTable($diff);
$tableFinal = $this->_sm->listTableDetails('autoinc_type_modification');
self::assertTrue($tableFinal->getColumn('id')->getAutoincrement());
}
}

class MoneyType extends Type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1394,4 +1394,31 @@ public function testCreateAndListSequences() : void
self::assertEquals($sequence2AllocationSize, $actualSequence2->getAllocationSize());
self::assertEquals($sequence2InitialValue, $actualSequence2->getInitialValue());
}

/**
* @group 2925
*/
public function testAlterTableChangePrimaryKey() : void
{
$tableFrom = new Table('primary_key_userid');
$column = $tableFrom->addColumn('user_id', 'integer');
$column->setAutoincrement(true);
$tableFrom->setPrimaryKey(['user_id']);
$this->_sm->dropAndCreateTable($tableFrom);

$tableFrom = $this->_sm->listTableDetails('primary_key_userid');
self::assertTrue($tableFrom->getColumn('user_id')->getAutoincrement());

$tableTo = new Table('primary_key_id');
$column = $tableTo->addColumn('id', 'integer');
$column->setAutoincrement(true);
$tableTo->setPrimaryKey(['id']);

$c = new Comparator();
$diff = $c->diffTable($tableFrom, $tableTo);

$this->_sm->alterTable($diff);
$tableFinal = $this->_sm->listTableDetails('autoinc_type_modification');
self::assertTrue($tableFinal->getColumn('id')->getAutoincrement());
}
}

0 comments on commit 1a0614b

Please sign in to comment.