Skip to content

Commit

Permalink
[8.x] Allow anonymous and class based migration coexisting (#37006)
Browse files Browse the repository at this point in the history
* Update test to fail

* Validate file path
  • Loading branch information
netpok committed Apr 15, 2021
1 parent d51133b commit 8d16ccc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Migrations/Migrator.php
Expand Up @@ -470,7 +470,7 @@ protected function resolvePath(string $path)
{
$class = $this->getMigrationClass($this->getMigrationName($path));

if (class_exists($class)) {
if (class_exists($class) && realpath($path) == (new ReflectionClass($class))->getFileName()) {
return new $class;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Migration/MigratorTest.php
Expand Up @@ -76,7 +76,7 @@ public function testPretendMigrate()
{
$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)');
$this->expectOutput('<info>CreatePeopleTable:</info> create unique index "people_email_unique" on "people" ("email")');
$this->expectOutput('<info>2015_10_04_000000_modify_people_table:</info> alter table "people" add column "first_name" varchar');
$this->expectOutput('<info>ModifyPeopleTable:</info> alter table "people" add column "first_name" varchar');
$this->expectOutput('<info>2016_10_04_000000_modify_people_table:</info> alter table "people" add column "last_name" varchar');

$this->subject->run([__DIR__.'/fixtures'], ['pretend' => true]);
Expand Down
Expand Up @@ -4,7 +4,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
class ModifyPeopleTable extends Migration
{
/**
* Run the migrations.
*
Expand All @@ -28,4 +29,4 @@ public function down()
$table->dropColumn('first_name');
});
}
};
}

0 comments on commit 8d16ccc

Please sign in to comment.