TableDiff.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. *
  15. * This software consists of voluntary contributions made by many individuals
  16. * and is licensed under the MIT license. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\DBAL\Schema;
  20. /**
  21. * Table Diff.
  22. *
  23. * @link www.doctrine-project.org
  24. * @since 2.0
  25. * @author Benjamin Eberlei <kontakt@beberlei.de>
  26. */
  27. class TableDiff
  28. {
  29. /**
  30. * @var string
  31. */
  32. public $name = null;
  33. /**
  34. * @var string|boolean
  35. */
  36. public $newName = false;
  37. /**
  38. * All added fields.
  39. *
  40. * @var \Doctrine\DBAL\Schema\Column[]
  41. */
  42. public $addedColumns;
  43. /**
  44. * All changed fields.
  45. *
  46. * @var \Doctrine\DBAL\Schema\Column[]
  47. */
  48. public $changedColumns = array();
  49. /**
  50. * All removed fields.
  51. *
  52. * @var \Doctrine\DBAL\Schema\Column[]
  53. */
  54. public $removedColumns = array();
  55. /**
  56. * Columns that are only renamed from key to column instance name.
  57. *
  58. * @var \Doctrine\DBAL\Schema\Column[]
  59. */
  60. public $renamedColumns = array();
  61. /**
  62. * All added indexes.
  63. *
  64. * @var \Doctrine\DBAL\Schema\Index[]
  65. */
  66. public $addedIndexes = array();
  67. /**
  68. * All changed indexes.
  69. *
  70. * @var \Doctrine\DBAL\Schema\Index[]
  71. */
  72. public $changedIndexes = array();
  73. /**
  74. * All removed indexes
  75. *
  76. * @var \Doctrine\DBAL\Schema\Index[]
  77. */
  78. public $removedIndexes = array();
  79. /**
  80. * All added foreign key definitions
  81. *
  82. * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[]
  83. */
  84. public $addedForeignKeys = array();
  85. /**
  86. * All changed foreign keys
  87. *
  88. * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[]
  89. */
  90. public $changedForeignKeys = array();
  91. /**
  92. * All removed foreign keys
  93. *
  94. * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[]
  95. */
  96. public $removedForeignKeys = array();
  97. /**
  98. * @var \Doctrine\DBAL\Schema\Table
  99. */
  100. public $fromTable;
  101. /**
  102. * Constructs an TableDiff object.
  103. *
  104. * @param string $tableName
  105. * @param \Doctrine\DBAL\Schema\Column[] $addedColumns
  106. * @param \Doctrine\DBAL\Schema\Column[] $changedColumns
  107. * @param \Doctrine\DBAL\Schema\Column[] $removedColumns
  108. * @param \Doctrine\DBAL\Schema\Index[] $addedIndexes
  109. * @param \Doctrine\DBAL\Schema\Index[] $changedIndexes
  110. * @param \Doctrine\DBAL\Schema\Index[] $removedIndexes
  111. * @param \Doctrine\DBAL\Schema\Table|null $fromTable
  112. */
  113. public function __construct($tableName, $addedColumns = array(),
  114. $changedColumns = array(), $removedColumns = array(), $addedIndexes = array(),
  115. $changedIndexes = array(), $removedIndexes = array(), Table $fromTable = null)
  116. {
  117. $this->name = $tableName;
  118. $this->addedColumns = $addedColumns;
  119. $this->changedColumns = $changedColumns;
  120. $this->removedColumns = $removedColumns;
  121. $this->addedIndexes = $addedIndexes;
  122. $this->changedIndexes = $changedIndexes;
  123. $this->removedIndexes = $removedIndexes;
  124. $this->fromTable = $fromTable;
  125. }
  126. }