Skip to content

Commit 64272b4

Browse files
committed
Display migration class name in pretendToRun
Due to backward compatibility, classic migrations (non-anonymous) should have their class name displayed while running migrations with --pretend, instead of the migration name, like anywhere else in the code.
1 parent 9cdb5cc commit 64272b4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Illuminate/Database/Migrations/Migrator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,12 @@ protected function runMigration($migration, $method)
410410
protected function pretendToRun($migration, $method)
411411
{
412412
foreach ($this->getQueries($migration, $method) as $query) {
413-
$name = $this->getMigrationName((new ReflectionClass($migration))->getFileName());
413+
$name = get_class($migration);
414+
415+
$reflectionClass = new ReflectionClass($migration);
416+
if ($reflectionClass->isAnonymous()) {
417+
$name = $this->getMigrationName($reflectionClass->getFileName());
418+
}
414419

415420
$this->note("<info>{$name}:</info> {$query['query']}");
416421
}

tests/Integration/Migration/MigratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public function testRollback()
7474

7575
public function testPretendMigrate()
7676
{
77-
$this->expectOutput('<info>2014_10_12_000000_create_people_table:</info> create table "people" ("id" integer not null primary key autoincrement, "name" varchar not null, "email" varchar not null, "password" varchar not null, "remember_token" varchar, "created_at" datetime, "updated_at" datetime)');
78-
$this->expectOutput('<info>2014_10_12_000000_create_people_table:</info> create unique index "people_email_unique" on "people" ("email")');
77+
$this->expectOutput('<info>CreatePeopleTable:</info> create table "people" ("id" integer not null primary key autoincrement, "name" varchar not null, "email" varchar not null, "password" varchar not null, "remember_token" varchar, "created_at" datetime, "updated_at" datetime)');
78+
$this->expectOutput('<info>CreatePeopleTable:</info> create unique index "people_email_unique" on "people" ("email")');
7979
$this->expectOutput('<info>2015_10_04_000000_modify_people_table:</info> alter table "people" add column "first_name" varchar');
8080
$this->expectOutput('<info>2016_10_04_000000_modify_people_table:</info> alter table "people" add column "last_name" varchar');
8181

0 commit comments

Comments
 (0)