Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Allow anonymous and class based migration coexisting #37006

Merged
merged 2 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Migrations/Migrator.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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');
});
}
};
}