TableDiff.php 3.88 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?php
/*
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
Benjamin Eberlei's avatar
Benjamin Eberlei committed
16
 * and is licensed under the MIT license. For more information, see
17 18 19 20 21 22
 * <http://www.doctrine-project.org>.
 */

namespace Doctrine\DBAL\Schema;

/**
Benjamin Morel's avatar
Benjamin Morel committed
23
 * Table Diff.
24
 *
Benjamin Morel's avatar
Benjamin Morel committed
25 26 27
 * @link   www.doctrine-project.org
 * @since  2.0
 * @author Benjamin Eberlei <kontakt@beberlei.de>
28 29 30
 */
class TableDiff
{
31 32 33 34 35 36
    /**
     * @var string
     */
    public $name = null;

    /**
Benjamin Morel's avatar
Benjamin Morel committed
37
     * @var string|boolean
38 39 40
     */
    public $newName = false;

41
    /**
Benjamin Morel's avatar
Benjamin Morel committed
42
     * All added fields.
43
     *
Benjamin Morel's avatar
Benjamin Morel committed
44
     * @var \Doctrine\DBAL\Schema\Column[]
45
     */
46
    public $addedColumns;
47 48

    /**
Benjamin Morel's avatar
Benjamin Morel committed
49
     * All changed fields.
50
     *
Benjamin Morel's avatar
Benjamin Morel committed
51
     * @var \Doctrine\DBAL\Schema\Column[]
52
     */
53
    public $changedColumns = array();
54 55

    /**
Benjamin Morel's avatar
Benjamin Morel committed
56
     * All removed fields.
57
     *
Benjamin Morel's avatar
Benjamin Morel committed
58
     * @var \Doctrine\DBAL\Schema\Column[]
59
     */
60
    public $removedColumns = array();
61

62 63 64
    /**
     * Columns that are only renamed from key to column instance name.
     *
Benjamin Morel's avatar
Benjamin Morel committed
65
     * @var \Doctrine\DBAL\Schema\Column[]
66 67 68
     */
    public $renamedColumns = array();

69
    /**
Benjamin Morel's avatar
Benjamin Morel committed
70
     * All added indexes.
71
     *
Benjamin Morel's avatar
Benjamin Morel committed
72
     * @var \Doctrine\DBAL\Schema\Index[]
73
     */
74
    public $addedIndexes = array();
75 76

    /**
Benjamin Morel's avatar
Benjamin Morel committed
77
     * All changed indexes.
78
     *
Benjamin Morel's avatar
Benjamin Morel committed
79
     * @var \Doctrine\DBAL\Schema\Index[]
80
     */
81
    public $changedIndexes = array();
82 83 84 85

    /**
     * All removed indexes
     *
Benjamin Morel's avatar
Benjamin Morel committed
86
     * @var \Doctrine\DBAL\Schema\Index[]
87
     */
88 89 90 91
    public $removedIndexes = array();

    /**
     * All added foreign key definitions
92
     *
Benjamin Morel's avatar
Benjamin Morel committed
93
     * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[]
94 95 96 97 98 99
     */
    public $addedForeignKeys = array();

    /**
     * All changed foreign keys
     *
Benjamin Morel's avatar
Benjamin Morel committed
100
     * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[]
101 102 103 104 105 106
     */
    public $changedForeignKeys = array();

    /**
     * All removed foreign keys
     *
Benjamin Morel's avatar
Benjamin Morel committed
107
     * @var \Doctrine\DBAL\Schema\ForeignKeyConstraint[]
108 109
     */
    public $removedForeignKeys = array();
110

111
    /**
Benjamin Morel's avatar
Benjamin Morel committed
112
     * @var \Doctrine\DBAL\Schema\Table
113 114 115
     */
    public $fromTable;

116 117 118
    /**
     * Constructs an TableDiff object.
     *
Benjamin Morel's avatar
Benjamin Morel committed
119 120 121 122 123 124 125 126
     * @param string                           $tableName
     * @param \Doctrine\DBAL\Schema\Column[]   $addedColumns
     * @param \Doctrine\DBAL\Schema\Column[]   $changedColumns
     * @param \Doctrine\DBAL\Schema\Column[]   $removedColumns
     * @param \Doctrine\DBAL\Schema\Index[]    $addedIndexes
     * @param \Doctrine\DBAL\Schema\Index[]    $changedIndexes
     * @param \Doctrine\DBAL\Schema\Index[]    $removedIndexes
     * @param \Doctrine\DBAL\Schema\Table|null $fromTable
127
     */
128 129
    public function __construct($tableName, $addedColumns = array(),
        $changedColumns = array(), $removedColumns = array(), $addedIndexes = array(),
130
        $changedIndexes = array(), $removedIndexes = array(), Table $fromTable = null)
131
    {
132
        $this->name = $tableName;
133 134 135
        $this->addedColumns = $addedColumns;
        $this->changedColumns = $changedColumns;
        $this->removedColumns = $removedColumns;
136 137 138
        $this->addedIndexes = $addedIndexes;
        $this->changedIndexes = $changedIndexes;
        $this->removedIndexes = $removedIndexes;
139
        $this->fromTable = $fromTable;
140
    }
141
}