@@ -74,8 +74,8 @@ public function __construct(
74
74
Container $ laravel ,
75
75
DatabaseMigrationRepository $ repository ,
76
76
Resolver $ resolver ,
77
- Filesystem $ files)
78
- {
77
+ Filesystem $ files
78
+ ) {
79
79
$ this ->laravel = $ laravel ;
80
80
$ this ->files = $ files ;
81
81
$ this ->resolver = $ resolver ;
@@ -116,9 +116,7 @@ public function run($paths = [], array $options = [])
116
116
// run each of the outstanding migrations against a database connection.
117
117
$ files = $ this ->getCommandFiles ($ paths );
118
118
119
- $ this ->requireFiles ($ migrations = $ this ->pendingMigrations (
120
- $ files , $ this ->repository ->getRan ()
121
- ));
119
+ $ migrations = $ this ->requirePendingMigrations ($ files );
122
120
123
121
// Once we have all these migrations that are outstanding we are ready to run
124
122
// we will go ahead and run them "up". This will execute each migration as
@@ -128,11 +126,53 @@ public function run($paths = [], array $options = [])
128
126
return $ migrations ;
129
127
}
130
128
129
+ /**
130
+ * @param array $paths
131
+ * @param array $options
132
+ * @return array
133
+ */
134
+ public function markAllCompleted ($ paths = [], array $ options = [])
135
+ {
136
+ $ files = $ this ->getCommandFiles ($ paths );
137
+
138
+ $ migrations = $ this ->requirePendingMigrations ($ files );
139
+
140
+ foreach ($ migrations as $ file ) {
141
+ $ this ->markFileCompleted ($ file );
142
+ }
143
+
144
+ $ this ->note ("<info>Marked all pending commands as completed</info> " );
145
+
146
+ return $ migrations ;
147
+ }
148
+
149
+ /**
150
+ * @param string $file
151
+ * @return void
152
+ */
153
+ protected function markFileCompleted ($ file )
154
+ {
155
+ $ name = $ this ->getCommandName ($ file );
156
+ $ this ->repository ->log ($ name );
157
+ }
158
+
159
+ /**
160
+ * @param array $files
161
+ * @return array
162
+ */
163
+ protected function requirePendingMigrations (array $ files = [])
164
+ {
165
+ $ this ->requireFiles ($ migrations = $ this ->pendingMigrations (
166
+ $ files , $ this ->repository ->getRan ()
167
+ ));
168
+ return $ migrations ;
169
+ }
170
+
131
171
/**
132
172
* Get the migration files that have not yet run.
133
173
*
134
- * @param array $files
135
- * @param array $ran
174
+ * @param array $files
175
+ * @param array $ran
136
176
* @return array
137
177
*/
138
178
protected function pendingMigrations ($ files , $ ran )
@@ -211,8 +251,8 @@ protected function runCommand($file, $pretend)
211
251
/**
212
252
* Pretend to run the migrations.
213
253
*
214
- * @param object|Command $command
215
- * @param string $method
254
+ * @param object|Command $command
255
+ * @param string $method
216
256
* @return void
217
257
*/
218
258
protected function pretendToRun ($ command , $ method )
@@ -227,8 +267,8 @@ protected function pretendToRun($command, $method)
227
267
/**
228
268
* Get all of the queries that would be run for a migration.
229
269
*
230
- * @param object|Command $command
231
- * @param string $method
270
+ * @param object|Command $command
271
+ * @param string $method
232
272
* @return array
233
273
*/
234
274
protected function getQueries ($ command , $ method )
@@ -248,7 +288,7 @@ protected function getQueries($command, $method)
248
288
/**
249
289
* Resolve a migration instance from a file.
250
290
*
251
- * @param string $file
291
+ * @param string $file
252
292
* @return object|Command
253
293
*/
254
294
public function resolve ($ file )
@@ -265,13 +305,13 @@ public function resolve($file)
265
305
/**
266
306
* Get all of the migration files in a given path.
267
307
*
268
- * @param string|array $paths
308
+ * @param string|array $paths
269
309
* @return array
270
310
*/
271
311
public function getCommandFiles ($ paths )
272
312
{
273
313
return Collection::make ($ paths )->flatMap (function ($ path ) {
274
- return $ this ->files ->glob ($ path. '/*_*.php ' );
314
+ return $ this ->files ->glob ($ path . '/*_*.php ' );
275
315
})->filter ()->sortBy (function ($ file ) {
276
316
return $ this ->getCommandName ($ file );
277
317
})->values ()->keyBy (function ($ file ) {
@@ -282,7 +322,7 @@ public function getCommandFiles($paths)
282
322
/**
283
323
* Require in all the migration files in a given path.
284
324
*
285
- * @param array $files
325
+ * @param array $files
286
326
* @return void
287
327
*/
288
328
public function requireFiles (array $ files )
@@ -295,7 +335,7 @@ public function requireFiles(array $files)
295
335
/**
296
336
* Get the name of the migration.
297
337
*
298
- * @param string $path
338
+ * @param string $path
299
339
* @return string
300
340
*/
301
341
public function getCommandName ($ path )
@@ -306,7 +346,7 @@ public function getCommandName($path)
306
346
/**
307
347
* Register a custom migration path.
308
348
*
309
- * @param string $path
349
+ * @param string $path
310
350
* @return void
311
351
*/
312
352
public function path ($ path )
@@ -327,12 +367,12 @@ public function paths()
327
367
/**
328
368
* Set the default connection name.
329
369
*
330
- * @param string $name
370
+ * @param string $name
331
371
* @return void
332
372
*/
333
373
public function setConnection ($ name )
334
374
{
335
- if (! is_null ($ name )) {
375
+ if (!is_null ($ name )) {
336
376
$ this ->resolver ->setDefaultConnection ($ name );
337
377
}
338
378
@@ -344,7 +384,7 @@ public function setConnection($name)
344
384
/**
345
385
* Resolve the database connection instance.
346
386
*
347
- * @param string $connection
387
+ * @param string $connection
348
388
* @return \Illuminate\Database\Connection
349
389
*/
350
390
public function resolveConnection ($ connection )
@@ -355,7 +395,7 @@ public function resolveConnection($connection)
355
395
/**
356
396
* Get the schema grammar out of a migration connection.
357
397
*
358
- * @param \Illuminate\Database\Connection $connection
398
+ * @param \Illuminate\Database\Connection $connection
359
399
* @return \Illuminate\Database\Schema\Grammars\Grammar
360
400
*/
361
401
protected function getSchemaGrammar ($ connection )
@@ -402,7 +442,7 @@ public function getFilesystem()
402
442
/**
403
443
* Raise a note event for the migrator.
404
444
*
405
- * @param string $message
445
+ * @param string $message
406
446
* @return void
407
447
*/
408
448
protected function note ($ message )
0 commit comments