Skip to content

Commit f362c8d

Browse files
Kosadchiykirill.osa
andauthored
fix rollback anonymous migrations (#9)
* fix rollback anonymous migrations * lint * fix old rollback Co-authored-by: kirill.osa <[email protected]>
1 parent 8feba79 commit f362c8d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Console/RollbackNewMigrations.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Umbrellio\Deploy\Console;
66

77
use Illuminate\Console\Command;
8+
use Illuminate\Database\Migrations\Migration;
89
use Illuminate\Support\Collection;
910
use Illuminate\Support\Facades\App;
1011
use Illuminate\Support\Facades\DB;
@@ -55,10 +56,12 @@ public function handle(): void
5556

5657
private function downMigrationFile(SplFileInfo $f): void
5758
{
58-
require_once $f->getPathname();
59+
$migration = require_once $f;
5960
$filename = explode('.php', $f->getRelativePathname())[0];
60-
$class = Str::studly(implode('_', array_slice(explode('_', $filename), 4)));
61-
$migration = new $class();
61+
if (!$migration instanceof Migration) {
62+
$class = Str::studly(implode('_', array_slice(explode('_', $filename), 4)));
63+
$migration = new $class();
64+
}
6265
if (method_exists($migration, 'down')) {
6366
$migration->down();
6467
DB::table(config('database.migrations', 'migrations'))->where('migration', $filename)->delete();

0 commit comments

Comments
 (0)