Unverified Commit 904d6759 authored by Michael Moravec's avatar Michael Moravec Committed by Sergei Morozov

Remove deprecated Table::addUnnamedForeignKeyConstraint() and Table::addNamedForeignKeyConstraint()

parent 3d5847a0
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* Removed `MysqlSessionInit` listener. * Removed `MysqlSessionInit` listener.
* Removed `MysqlPlatform::getCollationFieldDeclaration()`. * Removed `MysqlPlatform::getCollationFieldDeclaration()`.
* Removed `AbstractPlatform::getIdentityColumnNullInsertSQL()`. * Removed `AbstractPlatform::getIdentityColumnNullInsertSQL()`.
* Removed `Table::addUnnamedForeignKeyConstraint()` and `Table::addNamedForeignKeyConstraint()`.
## BC BREAK changes the `Driver::connect()` signature ## BC BREAK changes the `Driver::connect()` signature
......
...@@ -361,55 +361,16 @@ class Table extends AbstractAsset ...@@ -361,55 +361,16 @@ class Table extends AbstractAsset
* @param string[] $localColumnNames * @param string[] $localColumnNames
* @param string[] $foreignColumnNames * @param string[] $foreignColumnNames
* @param mixed[] $options * @param mixed[] $options
* @param string|null $constraintName * @param string|null $name
* *
* @return self * @return self
*/ */
public function addForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = [], $constraintName = null) public function addForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = [], $name = null)
{ {
if ($constraintName === null) { if ($name === null) {
$constraintName = $this->_generateIdentifierName(array_merge((array) $this->getName(), $localColumnNames), 'fk', $this->_getMaxIdentifierLength()); $name = $this->_generateIdentifierName(array_merge((array) $this->getName(), $localColumnNames), 'fk', $this->_getMaxIdentifierLength());
} }
return $this->addNamedForeignKeyConstraint($constraintName, $foreignTable, $localColumnNames, $foreignColumnNames, $options);
}
/**
* Adds a foreign key constraint.
*
* Name is to be generated by the database itself.
*
* @deprecated Use {@link addForeignKeyConstraint}
*
* @param Table|string $foreignTable Table schema instance or table name
* @param string[] $localColumnNames
* @param string[] $foreignColumnNames
* @param mixed[] $options
*
* @return self
*/
public function addUnnamedForeignKeyConstraint($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = [])
{
return $this->addForeignKeyConstraint($foreignTable, $localColumnNames, $foreignColumnNames, $options);
}
/**
* Adds a foreign key constraint with a given name.
*
* @deprecated Use {@link addForeignKeyConstraint}
*
* @param string $name
* @param Table|string $foreignTable Table schema instance or table name
* @param string[] $localColumnNames
* @param string[] $foreignColumnNames
* @param mixed[] $options
*
* @return self
*
* @throws SchemaException
*/
public function addNamedForeignKeyConstraint($name, $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = [])
{
if ($foreignTable instanceof Table) { if ($foreignTable instanceof Table) {
foreach ($foreignColumnNames as $columnName) { foreach ($foreignColumnNames as $columnName) {
if (! $foreignTable->hasColumn($columnName)) { if (! $foreignTable->hasColumn($columnName)) {
......
...@@ -164,7 +164,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -164,7 +164,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$column = $nestedSchemaTable->addColumn('id', 'integer'); $column = $nestedSchemaTable->addColumn('id', 'integer');
$column->setAutoincrement(true); $column->setAutoincrement(true);
$nestedSchemaTable->setPrimaryKey(['id']); $nestedSchemaTable->setPrimaryKey(['id']);
$nestedSchemaTable->addUnnamedForeignKeyConstraint($nestedRelatedTable, ['id'], ['id']); $nestedSchemaTable->addForeignKeyConstraint($nestedRelatedTable, ['id'], ['id']);
$this->schemaManager->createTable($nestedRelatedTable); $this->schemaManager->createTable($nestedRelatedTable);
$this->schemaManager->createTable($nestedSchemaTable); $this->schemaManager->createTable($nestedSchemaTable);
......
...@@ -589,7 +589,7 @@ abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCa ...@@ -589,7 +589,7 @@ abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCa
$oldTable = clone $newTable; $oldTable = clone $newTable;
$oldTable->addColumn('parent_id', 'integer'); $oldTable->addColumn('parent_id', 'integer');
$oldTable->addUnnamedForeignKeyConstraint('mytable', ['parent_id'], ['id']); $oldTable->addForeignKeyConstraint('mytable', ['parent_id'], ['id']);
$comparator = new Comparator(); $comparator = new Comparator();
$tableDiff = $comparator->diffTable($oldTable, $newTable); $tableDiff = $comparator->diffTable($oldTable, $newTable);
......
...@@ -680,11 +680,11 @@ class ComparatorTest extends TestCase ...@@ -680,11 +680,11 @@ class ComparatorTest extends TestCase
{ {
$tableA = new Table('foo'); $tableA = new Table('foo');
$tableA->addColumn('id', 'integer'); $tableA->addColumn('id', 'integer');
$tableA->addNamedForeignKeyConstraint('foo_constraint', 'bar', ['id'], ['id']); $tableA->addForeignKeyConstraint('bar', ['id'], ['id'], [], 'foo_constraint');
$tableB = new Table('foo'); $tableB = new Table('foo');
$tableB->addColumn('ID', 'integer'); $tableB->addColumn('ID', 'integer');
$tableB->addNamedForeignKeyConstraint('bar_constraint', 'bar', ['id'], ['id']); $tableB->addForeignKeyConstraint('bar', ['id'], ['id'], [], 'bar_constraint');
$c = new Comparator(); $c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB); $tableDiff = $c->diffTable($tableA, $tableB);
......
...@@ -51,7 +51,7 @@ class MySQLSchemaTest extends TestCase ...@@ -51,7 +51,7 @@ class MySQLSchemaTest extends TestCase
{ {
$tableOld = new Table('test'); $tableOld = new Table('test');
$tableOld->addColumn('foo_id', 'integer'); $tableOld->addColumn('foo_id', 'integer');
$tableOld->addUnnamedForeignKeyConstraint('test_foreign', ['foo_id'], ['foo_id']); $tableOld->addForeignKeyConstraint('test_foreign', ['foo_id'], ['foo_id']);
$sqls = []; $sqls = [];
foreach ($tableOld->getForeignKeys() as $fk) { foreach ($tableOld->getForeignKeys() as $fk) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment