4343use Config \Services ;
4444
4545/**
46- * Creates a new migration file .
46+ * Runs all new migrations .
4747 *
4848 * @package CodeIgniter\Commands
4949 */
50- class MigrateLatest extends BaseCommand
50+ class Migrate extends BaseCommand
5151{
5252 /**
5353 * The group the command is lumped under
@@ -69,7 +69,7 @@ class MigrateLatest extends BaseCommand
6969 *
7070 * @var string
7171 */
72- protected $ description = 'Migrates the database to the latest schema . ' ;
72+ protected $ description = 'Locates and runs all new migrations against the database . ' ;
7373
7474 /**
7575 * the Command's usage
@@ -93,7 +93,7 @@ class MigrateLatest extends BaseCommand
9393 protected $ options = [
9494 '-n ' => 'Set migration namespace ' ,
9595 '-g ' => 'Set database group ' ,
96- '-all ' => 'Set latest for all namespace , will ignore (-n) option ' ,
96+ '-all ' => 'Set for all namespaces , will ignore (-n) option ' ,
9797 ];
9898
9999 /**
@@ -104,22 +104,31 @@ class MigrateLatest extends BaseCommand
104104 public function run (array $ params = [])
105105 {
106106 $ runner = Services::migrations ();
107+ $ runner ->clearCliMessages ();
107108
108- CLI ::write (lang ('Migrations.toLatest ' ), 'yellow ' );
109+ CLI ::write (lang ('Migrations.latest ' ), 'yellow ' );
109110
110111 $ namespace = $ params ['-n ' ] ?? CLI ::getOption ('n ' );
111112 $ group = $ params ['-g ' ] ?? CLI ::getOption ('g ' );
112113
113114 try
114115 {
116+ // Check for 'all' namespaces
115117 if ($ this ->isAllNamespace ($ params ))
116118 {
117- $ runner ->latestAll ( $ group );
119+ $ runner ->setNamespace ( null );
118120 }
119- else
121+ // Check for a specified namespace
122+ elseif ($ namespace )
120123 {
121- $ runner ->latest ($ namespace, $ group );
124+ $ runner ->setNamespace ($ namespace );
122125 }
126+
127+ if (! $ runner ->latest ($ group ))
128+ {
129+ CLI ::write (lang ('Migrations.generalFault ' ), 'red ' );
130+ }
131+
123132 $ messages = $ runner ->getCliMessages ();
124133 foreach ($ messages as $ message )
125134 {
0 commit comments