Skip to content

Commit 87b100e

Browse files
authored
Adopt anonymous migrations (#571)
1 parent 9b32edd commit 87b100e

File tree

56 files changed

+110
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+110
-113
lines changed

src/Generators/MigrationGenerator.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ protected function createMigrations(array $tables, $overwrite = false): array
106106

107107
protected function populateStub(string $stub, Model $model)
108108
{
109-
$stub = str_replace('{{ class }}', $this->getClassName($model), $stub);
110109
$stub = str_replace('{{ table }}', $model->tableName(), $stub);
111110
$stub = str_replace('{{ definition }}', $this->buildDefinition($model), $stub);
112111

@@ -123,7 +122,6 @@ protected function populateStub(string $stub, Model $model)
123122

124123
protected function populatePivotStub(string $stub, array $segments)
125124
{
126-
$stub = str_replace('{{ class }}', $this->getPivotClassName($segments), $stub);
127125
$stub = str_replace('{{ table }}', $this->getPivotTableName($segments), $stub);
128126
$stub = str_replace('{{ definition }}', $this->buildPivotTableDefinition($segments), $stub);
129127

@@ -136,7 +134,6 @@ protected function populatePivotStub(string $stub, array $segments)
136134

137135
protected function populatePolyStub(string $stub, string $parentTable)
138136
{
139-
$stub = str_replace('{{ class }}', $this->getPolyClassName($parentTable), $stub);
140137
$stub = str_replace('{{ table }}', $this->getPolyTableName($parentTable), $stub);
141138
$stub = str_replace('{{ definition }}', $this->buildPolyTableDefinition($parentTable), $stub);
142139

stubs/migration.stub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class {{ class }} extends Migration
7+
return new class extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -27,4 +27,4 @@ class {{ class }} extends Migration
2727
{
2828
Schema::dropIfExists('{{ table }}');
2929
}
30-
}
30+
};

tests/fixtures/migrations/belongs-to-many-duplicated-company.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreateCompaniesTable extends Migration
7+
return new class extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -29,4 +29,4 @@ public function down()
2929
{
3030
Schema::dropIfExists('companies');
3131
}
32-
}
32+
};

tests/fixtures/migrations/belongs-to-many-duplicated-people.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreatePeopleTable extends Migration
7+
return new class extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -29,4 +29,4 @@ public function down()
2929
{
3030
Schema::dropIfExists('people');
3131
}
32-
}
32+
};

tests/fixtures/migrations/belongs-to-many-duplicated-pivot.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreateCompanyPersonTable extends Migration
7+
return new class extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -28,4 +28,4 @@ public function down()
2828
{
2929
Schema::dropIfExists('company_person');
3030
}
31-
}
31+
};

tests/fixtures/migrations/belongs-to-many-key-constraints.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreateJourneysTable extends Migration
7+
return new class extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -34,4 +34,4 @@ public function down()
3434
{
3535
Schema::dropIfExists('journeys');
3636
}
37-
}
37+
};

tests/fixtures/migrations/belongs-to-many-pivot-key-constraints.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreateDiaryJourneyTable extends Migration
7+
return new class extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -32,4 +32,4 @@ public function down()
3232
{
3333
Schema::dropIfExists('diary_journey');
3434
}
35-
}
35+
};

tests/fixtures/migrations/belongs-to-many-pivot.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreateDiaryJourneyTable extends Migration
7+
return new class extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -28,4 +28,4 @@ public function down()
2828
{
2929
Schema::dropIfExists('diary_journey');
3030
}
31-
}
31+
};

tests/fixtures/migrations/belongs-to-many.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreateJourneysTable extends Migration
7+
return new class extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -30,4 +30,4 @@ public function down()
3030
{
3131
Schema::dropIfExists('journeys');
3232
}
33-
}
33+
};

tests/fixtures/migrations/boolean-column-default.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreatePostsTable extends Migration
7+
return new class extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -34,4 +34,4 @@ public function down()
3434
{
3535
Schema::dropIfExists('posts');
3636
}
37-
}
37+
};

0 commit comments

Comments
 (0)