@@ 98-117 (lines=20) @@ | ||
95 | * @param string[] $columnNames |
|
96 | * @param string|null $indexName |
|
97 | */ |
|
98 | public function addIndex( |
|
99 | Schema $schema, |
|
100 | QueryBag $queries, |
|
101 | $tableName, |
|
102 | array $columnNames, |
|
103 | $indexName = null |
|
104 | ) { |
|
105 | if (!$indexName) { |
|
106 | $indexName = $this->nameGenerator->generateIndexName($tableName, $columnNames); |
|
107 | } |
|
108 | $index = new Index($indexName, $columnNames); |
|
109 | $diff = new TableDiff($tableName); |
|
110 | $diff->addedIndexes = [$indexName => $index]; |
|
111 | ||
112 | $renameQuery = new SqlMigrationQuery( |
|
113 | $this->platform->getAlterTableSQL($diff) |
|
114 | ); |
|
115 | ||
116 | $queries->addQuery($renameQuery); |
|
117 | } |
|
118 | ||
119 | /** |
|
120 | * Create an unique index without check of table and columns existence. |
|
@@ 129-148 (lines=20) @@ | ||
126 | * @param string[] $columnNames |
|
127 | * @param string|null $indexName |
|
128 | */ |
|
129 | public function addUniqueIndex( |
|
130 | Schema $schema, |
|
131 | QueryBag $queries, |
|
132 | $tableName, |
|
133 | array $columnNames, |
|
134 | $indexName = null |
|
135 | ) { |
|
136 | if (!$indexName) { |
|
137 | $indexName = $this->nameGenerator->generateIndexName($tableName, $columnNames, true); |
|
138 | } |
|
139 | $index = new Index($indexName, $columnNames, true); |
|
140 | $diff = new TableDiff($tableName); |
|
141 | $diff->addedIndexes = [$indexName => $index]; |
|
142 | ||
143 | $renameQuery = new SqlMigrationQuery( |
|
144 | $this->platform->getAlterTableSQL($diff) |
|
145 | ); |
|
146 | ||
147 | $queries->addQuery($renameQuery); |
|
148 | } |
|
149 | ||
150 | /** |
|
151 | * Create a foreign key constraint without check of table and columns existence. |