@@ 345-356 (lines=12) @@ | ||
342 | * |
|
343 | * @return void |
|
344 | */ |
|
345 | public static function migrate($dir = null) |
|
346 | { |
|
347 | if (is_null($dir)) { |
|
348 | $dir = __DIR__.'/../database/migrations'; |
|
349 | } |
|
350 | ||
351 | foreach (glob($dir.'/*.php') as $file) { |
|
352 | require_once $file; |
|
353 | $table = pathinfo($file)['filename']; |
|
354 | (new $table())->up(); |
|
355 | } |
|
356 | } |
|
357 | ||
358 | /** |
|
359 | * Drop tables. |
|
@@ 365-376 (lines=12) @@ | ||
362 | * |
|
363 | * @return void |
|
364 | */ |
|
365 | public static function rollback($dir = null) |
|
366 | { |
|
367 | if (is_null($dir)) { |
|
368 | $dir = __DIR__.'/../database/migrations'; |
|
369 | } |
|
370 | ||
371 | foreach (glob($dir.'/*.php') as $file) { |
|
372 | require_once $file; |
|
373 | $table = pathinfo($file)['filename']; |
|
374 | (new $table())->down(); |
|
375 | } |
|
376 | } |
|
377 | ||
378 | /** |
|
379 | * Drop and migrate fresh tables. |