'The migration file name', ]; /** * the Command's Options * * @var array */ protected $options = [ '-n' => 'Set migration namespace', ]; /** * Creates a new migration file with the current timestamp. * * @param array $params */ public function run(array $params = []) { helper('inflector'); $name = array_shift($params); if (empty($name)) { $name = CLI::prompt(lang('Migrations.nameMigration')); } if (empty($name)) { CLI::error(lang('Migrations.badCreateName')); return; } $ns = $params['-n'] ?? CLI::getOption('n'); $homepath = APPPATH; if (! empty($ns)) { // Get all namespaces from PSR4 paths. $config = new Autoload(); $namespaces = $config->psr4; foreach ($namespaces as $namespace => $path) { if ($namespace === $ns) { $homepath = realpath($path); break; } } } else { $ns = 'App'; } // Always use UTC/GMT so global teams can work together $config = config('Migrations'); $fileName = gmdate($config->timestampFormat) . $name; // full path $path = $homepath . '/Database/Migrations/' . $fileName . '.php'; // Class name should be pascal case now (camel case with upper first letter) $name = pascalize($name); $template = <<