| @@ 336-347 (lines=12) @@ | ||
| 333 | * |
|
| 334 | * @return void |
|
| 335 | */ |
|
| 336 | public static function migrate($dir = null) |
|
| 337 | { |
|
| 338 | if (is_null($dir)) { |
|
| 339 | $dir = __DIR__.'/../database/migrations'; |
|
| 340 | } |
|
| 341 | ||
| 342 | foreach (glob($dir.'/*.php') as $file) { |
|
| 343 | require_once $file; |
|
| 344 | $table = pathinfo($file)['filename']; |
|
| 345 | (new $table())->up(); |
|
| 346 | } |
|
| 347 | } |
|
| 348 | ||
| 349 | /** |
|
| 350 | * Drop tables. |
|
| @@ 356-367 (lines=12) @@ | ||
| 353 | * |
|
| 354 | * @return void |
|
| 355 | */ |
|
| 356 | public static function rollback($dir = null) |
|
| 357 | { |
|
| 358 | if (is_null($dir)) { |
|
| 359 | $dir = __DIR__.'/../database/migrations'; |
|
| 360 | } |
|
| 361 | ||
| 362 | foreach (glob($dir.'/*.php') as $file) { |
|
| 363 | require_once $file; |
|
| 364 | $table = pathinfo($file)['filename']; |
|
| 365 | (new $table())->down(); |
|
| 366 | } |
|
| 367 | } |
|
| 368 | ||
| 369 | /** |
|
| 370 | * Drop and migrate fresh tables. |
|