Exception
2 years ago
Visitor
9 months ago
AbstractAsset.php
2 years ago
AbstractSchemaManager.php
9 months ago
Column.php
2 years ago
ColumnDiff.php
2 years ago
Comparator.php
2 years ago
Constraint.php
2 years ago
DB2SchemaManager.php
2 years ago
DefaultSchemaManagerFactory.php
2 years ago
ForeignKeyConstraint.php
9 months ago
Identifier.php
2 years ago
Index.php
2 years ago
LegacySchemaManagerFactory.php
2 years ago
MySQLSchemaManager.php
9 months ago
OracleSchemaManager.php
2 years ago
PostgreSQLSchemaManager.php
9 months ago
SQLServerSchemaManager.php
9 months ago
Schema.php
2 years ago
SchemaConfig.php
2 years ago
SchemaDiff.php
2 years ago
SchemaException.php
2 years ago
SchemaManagerFactory.php
2 years ago
Sequence.php
2 years ago
SqliteSchemaManager.php
8 months ago
Table.php
2 years ago
TableDiff.php
2 years ago
UniqueConstraint.php
2 years ago
View.php
2 years ago
TableDiff.php
127 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Doctrine\DBAL\Schema; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform; |
| 5 | use MailPoetVendor\Doctrine\Deprecations\Deprecation; |
| 6 | use function array_filter; |
| 7 | use function array_values; |
| 8 | use function count; |
| 9 | class TableDiff |
| 10 | { |
| 11 | public $name; |
| 12 | public $newName = \false; |
| 13 | public $addedColumns; |
| 14 | public $changedColumns = []; |
| 15 | public $removedColumns = []; |
| 16 | public $renamedColumns = []; |
| 17 | public $addedIndexes = []; |
| 18 | public $changedIndexes = []; |
| 19 | public $removedIndexes = []; |
| 20 | public $renamedIndexes = []; |
| 21 | public $addedForeignKeys = []; |
| 22 | public $changedForeignKeys = []; |
| 23 | public $removedForeignKeys = []; |
| 24 | public $fromTable; |
| 25 | public function __construct($tableName, $addedColumns = [], $modifiedColumns = [], $droppedColumns = [], $addedIndexes = [], $changedIndexes = [], $removedIndexes = [], ?Table $fromTable = null, $addedForeignKeys = [], $changedForeignKeys = [], $removedForeignKeys = [], $renamedColumns = [], $renamedIndexes = []) |
| 26 | { |
| 27 | $this->name = $tableName; |
| 28 | $this->addedColumns = $addedColumns; |
| 29 | $this->changedColumns = $modifiedColumns; |
| 30 | $this->renamedColumns = $renamedColumns; |
| 31 | $this->removedColumns = $droppedColumns; |
| 32 | $this->addedIndexes = $addedIndexes; |
| 33 | $this->changedIndexes = $changedIndexes; |
| 34 | $this->renamedIndexes = $renamedIndexes; |
| 35 | $this->removedIndexes = $removedIndexes; |
| 36 | $this->addedForeignKeys = $addedForeignKeys; |
| 37 | $this->changedForeignKeys = $changedForeignKeys; |
| 38 | $this->removedForeignKeys = $removedForeignKeys; |
| 39 | if ($fromTable === null) { |
| 40 | Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5678', 'Not passing the $fromTable to %s is deprecated.', __METHOD__); |
| 41 | } |
| 42 | $this->fromTable = $fromTable; |
| 43 | } |
| 44 | public function getName(AbstractPlatform $platform) |
| 45 | { |
| 46 | return new Identifier($this->fromTable instanceof Table ? $this->fromTable->getQuotedName($platform) : $this->name); |
| 47 | } |
| 48 | public function getNewName() |
| 49 | { |
| 50 | Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5663', '%s is deprecated. Rename tables via AbstractSchemaManager::renameTable() instead.', __METHOD__); |
| 51 | if ($this->newName === \false) { |
| 52 | return \false; |
| 53 | } |
| 54 | return new Identifier($this->newName); |
| 55 | } |
| 56 | public function getOldTable() : ?Table |
| 57 | { |
| 58 | return $this->fromTable; |
| 59 | } |
| 60 | public function getAddedColumns() : array |
| 61 | { |
| 62 | return array_values($this->addedColumns); |
| 63 | } |
| 64 | public function getModifiedColumns() : array |
| 65 | { |
| 66 | return array_values($this->changedColumns); |
| 67 | } |
| 68 | public function getDroppedColumns() : array |
| 69 | { |
| 70 | return array_values($this->removedColumns); |
| 71 | } |
| 72 | public function getRenamedColumns() : array |
| 73 | { |
| 74 | return $this->renamedColumns; |
| 75 | } |
| 76 | public function getAddedIndexes() : array |
| 77 | { |
| 78 | return array_values($this->addedIndexes); |
| 79 | } |
| 80 | public function unsetAddedIndex(Index $index) : void |
| 81 | { |
| 82 | $this->addedIndexes = array_filter($this->addedIndexes, static function (Index $addedIndex) use($index) : bool { |
| 83 | return $addedIndex !== $index; |
| 84 | }); |
| 85 | } |
| 86 | public function getModifiedIndexes() : array |
| 87 | { |
| 88 | return array_values($this->changedIndexes); |
| 89 | } |
| 90 | public function getDroppedIndexes() : array |
| 91 | { |
| 92 | return array_values($this->removedIndexes); |
| 93 | } |
| 94 | public function unsetDroppedIndex(Index $index) : void |
| 95 | { |
| 96 | $this->removedIndexes = array_filter($this->removedIndexes, static function (Index $removedIndex) use($index) : bool { |
| 97 | return $removedIndex !== $index; |
| 98 | }); |
| 99 | } |
| 100 | public function getRenamedIndexes() : array |
| 101 | { |
| 102 | return $this->renamedIndexes; |
| 103 | } |
| 104 | public function getAddedForeignKeys() : array |
| 105 | { |
| 106 | return $this->addedForeignKeys; |
| 107 | } |
| 108 | public function getModifiedForeignKeys() : array |
| 109 | { |
| 110 | return $this->changedForeignKeys; |
| 111 | } |
| 112 | public function getDroppedForeignKeys() : array |
| 113 | { |
| 114 | return $this->removedForeignKeys; |
| 115 | } |
| 116 | public function unsetDroppedForeignKey($foreignKey) : void |
| 117 | { |
| 118 | $this->removedForeignKeys = array_filter($this->removedForeignKeys, static function ($removedForeignKey) use($foreignKey) : bool { |
| 119 | return $removedForeignKey !== $foreignKey; |
| 120 | }); |
| 121 | } |
| 122 | public function isEmpty() : bool |
| 123 | { |
| 124 | return count($this->addedColumns) === 0 && count($this->changedColumns) === 0 && count($this->removedColumns) === 0 && count($this->renamedColumns) === 0 && count($this->addedIndexes) === 0 && count($this->changedIndexes) === 0 && count($this->removedIndexes) === 0 && count($this->renamedIndexes) === 0 && count($this->addedForeignKeys) === 0 && count($this->changedForeignKeys) === 0 && count($this->removedForeignKeys) === 0; |
| 125 | } |
| 126 | } |
| 127 |