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 @@
* Removed `MysqlSessionInit` listener.
* Removed `MysqlPlatform::getCollationFieldDeclaration()`.
* Removed `AbstractPlatform::getIdentityColumnNullInsertSQL()`.
* Removed `Table::addUnnamedForeignKeyConstraint()` and `Table::addNamedForeignKeyConstraint()`.
## BC BREAK changes the `Driver::connect()` signature
......
......@@ -361,55 +361,16 @@ 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 === null) {
$constraintName = $this->_generateIdentifierName(array_merge((array) $this->getName(), $localColumnNames), 'fk', $this->_getMaxIdentifierLength());
if ($name === null) {
$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)) {
......
......@@ -164,7 +164,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);
......
......@@ -589,7 +589,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);
......
......@@ -680,11 +680,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);
......
......@@ -51,7 +51,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