Skip to content

Commit 4c0e15c

Browse files
Document the new Migration::shouldRun() feature (#10277)
* Update migrations.md * Update migrations.md * wording * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 5e9ae53 commit 4c0e15c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

migrations.md

+15
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ public function up(): void
134134
}
135135
```
136136

137+
<a name="skipping-migrations"></a>
138+
#### Skipping Migrations
139+
140+
Sometimes a migration might be meant to support a feature that is not yet active and you do not want it to run yet. In this case you may define a `shouldRun` method on the migration. If the `shouldRun` method returns `false`, the migration will be skipped:
141+
142+
```php
143+
/**
144+
* Determine if this migration should run.
145+
*/
146+
public function shouldRun(): bool
147+
{
148+
return Feature::active(Flights::class);
149+
}
150+
```
151+
137152
<a name="running-migrations"></a>
138153
## Running Migrations
139154

0 commit comments

Comments
 (0)