-
Notifications
You must be signed in to change notification settings - Fork 2
/
ForeignKey.php
52 lines (44 loc) · 1.58 KB
/
ForeignKey.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Fregata\Adapter\Doctrine\DBAL\ForeignKey;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Table;
/**
* Represent a foreign key constraint to keep after a migration
*/
class ForeignKey
{
private ForeignKeyConstraint $constraint;
private string $tableName;
/** @var string[] */
private array $allowNull;
/**
* @param ForeignKeyConstraint $constraint the foreign key constraint in the target database
* @param string $tableName the local table name
* Required as of a Doctrine bug which prevents Fregata from getting this
* information from the constraint object
* @param string[] $allowNull local column names you need to drop NOT NULL during the migration,
* the columns will be set back to NOT NULL afterwards
* @see https://github.com/doctrine/dbal/issues/4506
*/
public function __construct(ForeignKeyConstraint $constraint, string $tableName, array $allowNull = [])
{
$this->constraint = $constraint;
$this->tableName = $tableName;
$this->allowNull = $allowNull;
}
public function getConstraint(): ForeignKeyConstraint
{
return $this->constraint;
}
public function getTableName(): string
{
return $this->tableName;
}
/**
* @return string[]
*/
public function getAllowNull(): array
{
return $this->allowNull;
}
}