Unverified Commit 2af4b6e4 authored by Michael Moravec's avatar Michael Moravec Committed by Sergei Morozov

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

parent 9ff77b8b
......@@ -8,6 +8,7 @@
* Removed `MysqlSessionInit` listener.
* Removed `MysqlPlatform::getCollationFieldDeclaration()`.
* Removed `AbstractPlatform::getIdentityColumnNullInsertSQL()`.
* Removed `Table::addUnnamedForeignKeyConstraint()` and `Table::addNamedForeignKeyConstraint()`.
## BC BREAK `Connection::ping()` returns `void`.
......
......@@ -364,59 +364,20 @@ class Table extends AbstractAsset
* @param string[] $localColumnNames
* @param string[] $foreignColumnNames
* @param mixed[] $options
* @param string|null $constraintName
* @param string|null $name
*
* @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) {
$constraintName = $this->_generateIdentifierName(
if (! $name) {
$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) {
foreach ($foreignColumnNames as $columnName) {
if (! $foreignTable->hasColumn($columnName)) {
......
......@@ -161,7 +161,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$column = $nestedSchemaTable->addColumn('id', 'integer');
$column->setAutoincrement(true);
$nestedSchemaTable->setPrimaryKey(['id']);
$nestedSchemaTable->addUnnamedForeignKeyConstraint($nestedRelatedTable, ['id'], ['id']);
$nestedSchemaTable->addForeignKeyConstraint($nestedRelatedTable, ['id'], ['id']);
$this->schemaManager->createTable($nestedRelatedTable);
$this->schemaManager->createTable($nestedSchemaTable);
......
......@@ -585,7 +585,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
$oldTable = clone $newTable;
$oldTable->addColumn('parent_id', 'integer');
$oldTable->addUnnamedForeignKeyConstraint('mytable', ['parent_id'], ['id']);
$oldTable->addForeignKeyConstraint('mytable', ['parent_id'], ['id']);
$comparator = new Comparator();
$tableDiff = $comparator->diffTable($oldTable, $newTable);
......
......@@ -681,11 +681,11 @@ class ComparatorTest extends TestCase
{
$tableA = new Table('foo');
$tableA->addColumn('id', 'integer');
$tableA->addNamedForeignKeyConstraint('foo_constraint', 'bar', ['id'], ['id']);
$tableA->addForeignKeyConstraint('bar', ['id'], ['id'], [], 'foo_constraint');
$tableB = new Table('foo');
$tableB->addColumn('ID', 'integer');
$tableB->addNamedForeignKeyConstraint('bar_constraint', 'bar', ['id'], ['id']);
$tableB->addForeignKeyConstraint('bar', ['id'], ['id'], [], 'bar_constraint');
$c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB);
......
......@@ -53,7 +53,7 @@ class MySQLSchemaTest extends TestCase
{
$tableOld = new Table('test');
$tableOld->addColumn('foo_id', 'integer');
$tableOld->addUnnamedForeignKeyConstraint('test_foreign', ['foo_id'], ['foo_id']);
$tableOld->addForeignKeyConstraint('test_foreign', ['foo_id'], ['foo_id']);
$sqls = [];
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