TableDiff.php 3.6KB

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