|
@@ 173-189 (lines=17) @@
|
| 170 |
|
* |
| 171 |
|
* @param ModelInterface[] $models |
| 172 |
|
*/ |
| 173 |
|
protected function buildAlter(array $models) |
| 174 |
|
{ |
| 175 |
|
$fromSchema = $this->connection->getSchemaManager()->createSchema(); |
| 176 |
|
$toSchema = clone $fromSchema; |
| 177 |
|
|
| 178 |
|
foreach ($models as $model) { |
| 179 |
|
if ($toSchema->hasTable($model->table())) { |
| 180 |
|
$toSchema->dropTable($model->table()); |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
$this->createTable($toSchema, $model); |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
$sql = $fromSchema->getMigrateToSql($toSchema, $this->connection->getDatabasePlatform()); |
| 187 |
|
|
| 188 |
|
$this->queries = array_merge($this->queries, $sql); |
| 189 |
|
} |
| 190 |
|
|
| 191 |
|
/** |
| 192 |
|
* Creates table from model into schema |
|
@@ 268-284 (lines=17) @@
|
| 265 |
|
* |
| 266 |
|
* @param ModelInterface[] $models |
| 267 |
|
*/ |
| 268 |
|
protected function buildDrop(array $models) |
| 269 |
|
{ |
| 270 |
|
$fromSchema = $this->connection->getSchemaManager()->createSchema(); |
| 271 |
|
$toSchema = clone $fromSchema; |
| 272 |
|
|
| 273 |
|
foreach ($models as $model) { |
| 274 |
|
if (!$toSchema->hasTable($model->table())) { |
| 275 |
|
continue; |
| 276 |
|
} |
| 277 |
|
|
| 278 |
|
$toSchema->dropTable($model->table()); |
| 279 |
|
} |
| 280 |
|
|
| 281 |
|
$sql = $fromSchema->getMigrateToSql($toSchema, $this->connection->getDatabasePlatform()); |
| 282 |
|
|
| 283 |
|
$this->queries = array_merge($this->queries, $sql); |
| 284 |
|
} |
| 285 |
|
|
| 286 |
|
/** |
| 287 |
|
* Executes query |