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