TableDiff.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 LGPL. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\DBAL\Schema;
  20. /**
  21. * Table Diff
  22. *
  23. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
  24. * @link www.doctrine-project.org
  25. * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
  26. * @license http://ez.no/licenses/new_bsd New BSD License
  27. * @since 2.0
  28. * @author Benjamin Eberlei <kontakt@beberlei.de>
  29. */
  30. class TableDiff
  31. {
  32. /**
  33. * @var string
  34. */
  35. public $name = null;
  36. /**
  37. * @var string
  38. */
  39. public $newName = false;
  40. /**
  41. * All added fields
  42. *
  43. * @var array(string=>Column)
  44. */
  45. public $addedColumns;
  46. /**
  47. * All changed fields
  48. *
  49. * @var array(string=>Column)
  50. */
  51. public $changedColumns = array();
  52. /**
  53. * All removed fields
  54. *
  55. * @var array(string=>Column)
  56. */
  57. public $removedColumns = array();
  58. /**
  59. * Columns that are only renamed from key to column instance name.
  60. *
  61. * @var array(string=>Column)
  62. */
  63. public $renamedColumns = array();
  64. /**
  65. * All added indexes
  66. *
  67. * @var array(string=>Index)
  68. */
  69. public $addedIndexes = array();
  70. /**
  71. * All changed indexes
  72. *
  73. * @var array(string=>Index)
  74. */
  75. public $changedIndexes = array();
  76. /**
  77. * All removed indexes
  78. *
  79. * @var array(string=>bool)
  80. */
  81. public $removedIndexes = array();
  82. /**
  83. * All added foreign key definitions
  84. *
  85. * @var array
  86. */
  87. public $addedForeignKeys = array();
  88. /**
  89. * All changed foreign keys
  90. *
  91. * @var array
  92. */
  93. public $changedForeignKeys = array();
  94. /**
  95. * All removed foreign keys
  96. *
  97. * @var array
  98. */
  99. public $removedForeignKeys = array();
  100. /**
  101. * Constructs an TableDiff object.
  102. *
  103. * @param array(string=>Column) $addedColumns
  104. * @param array(string=>Column) $changedColumns
  105. * @param array(string=>bool) $removedColumns
  106. * @param array(string=>Index) $addedIndexes
  107. * @param array(string=>Index) $changedIndexes
  108. * @param array(string=>bool) $removedIndexes
  109. */
  110. public function __construct($tableName, $addedColumns = array(),
  111. $changedColumns = array(), $removedColumns = array(), $addedIndexes = array(),
  112. $changedIndexes = array(), $removedIndexes = array())
  113. {
  114. $this->name = $tableName;
  115. $this->addedColumns = $addedColumns;
  116. $this->changedColumns = $changedColumns;
  117. $this->removedColumns = $removedColumns;
  118. $this->addedIndexes = $addedIndexes;
  119. $this->changedIndexes = $changedIndexes;
  120. $this->removedIndexes = $removedIndexes;
  121. }
  122. }