| @@ 154-167 (lines=14) @@ | ||
| 151 | * |
|
| 152 | * @return string |
|
| 153 | */ |
|
| 154 | public function runMigration($file) |
|
| 155 | { |
|
| 156 | $migration = $this->getMigrationObjectByFileName($file); |
|
| 157 | ||
| 158 | $this->disableBitrixIblockHelperCache(); |
|
| 159 | ||
| 160 | $this->checkTransactionAndRun($migration, function () use ($migration, $file) { |
|
| 161 | if ($migration->up() === false) { |
|
| 162 | throw new Exception("Migration up from {$file}.php returned false"); |
|
| 163 | } |
|
| 164 | }); |
|
| 165 | ||
| 166 | $this->logSuccessfulMigration($file); |
|
| 167 | } |
|
| 168 | ||
| 169 | /** |
|
| 170 | * Log successful migration. |
|
| @@ 222-233 (lines=12) @@ | ||
| 219 | * |
|
| 220 | * @return mixed |
|
| 221 | */ |
|
| 222 | public function rollbackMigration($file) |
|
| 223 | { |
|
| 224 | $migration = $this->getMigrationObjectByFileName($file); |
|
| 225 | ||
| 226 | $this->checkTransactionAndRun($migration, function () use ($migration, $file) { |
|
| 227 | if ($migration->down() === false) { |
|
| 228 | throw new Exception("<error>Can't rollback migration:</error> {$file}.php"); |
|
| 229 | } |
|
| 230 | }); |
|
| 231 | ||
| 232 | $this->removeSuccessfulMigrationFromLog($file); |
|
| 233 | } |
|
| 234 | ||
| 235 | /** |
|
| 236 | * Remove a migration name from the database so it can be run again. |
|