Server : nginx/1.20.2 System : Linux VM-4-4-centos 3.10.0-1160.66.1.el7.x86_64 #1 SMP Wed May 18 16:02:34 UTC 2022 x86_64 User : www ( 1000) PHP Version : 5.6.40 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv Directory : /www/wwwroot/greatapp.cn/vendor/topthink/think-migration/src/command/migrate/ |
<?php // +---------------------------------------------------------------------- // | TopThink [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- // | Copyright (c) 2016 http://www.topthink.com All rights reserved. // +---------------------------------------------------------------------- // | Author: zhangyajun <448901948@qq.com> // +---------------------------------------------------------------------- namespace think\migration\command\migrate; use think\console\input\Option as InputOption; use think\console\Input; use think\console\Output; use think\migration\command\Migrate; class Status extends Migrate { /** * {@inheritdoc} */ protected function configure() { $this->setName('migrate:status') ->setDescription('Show migration status') ->addOption('--format', '-f', InputOption::VALUE_REQUIRED, 'The output format: text or json. Defaults to text.') ->setHelp(<<<EOT The <info>migrate:status</info> command prints a list of all migrations, along with their current status <info>php console migrate:status</info> <info>php console migrate:status -f json</info> EOT ); } /** * Show the migration status. * * @param Input $input * @param Output $output * @return integer 0 if all migrations are up, or an error code */ protected function execute(Input $input, Output $output) { $format = $input->getOption('format'); if (null !== $format) { $output->writeln('<info>using format</info> ' . $format); } // print the status return $this->printStatus($format); } protected function printStatus($format = null) { $output = $this->output; $migrations = []; if (count($this->getMigrations())) { // TODO - rewrite using Symfony Table Helper as we already have this library // included and it will fix formatting issues (e.g drawing the lines) $output->writeln(''); $output->writeln(' Status Migration ID Started Finished Migration Name '); $output->writeln('----------------------------------------------------------------------------------'); $versions = $this->getVersionLog(); $maxNameLength = $versions ? max(array_map(function ($version) { return strlen($version['migration_name']); }, $versions)) : 0; foreach ($this->getMigrations() as $migration) { $version = array_key_exists($migration->getVersion(), $versions) ? $versions[$migration->getVersion()] : false; if ($version) { $status = ' <info>up</info> '; } else { $status = ' <error>down</error> '; } $maxNameLength = max($maxNameLength, strlen($migration->getName())); $output->writeln(sprintf('%s %14.0f %19s %19s <comment>%s</comment>', $status, $migration->getVersion(), $version['start_time'], $version['end_time'], $migration->getName())); if ($version && $version['breakpoint']) { $output->writeln(' <error>BREAKPOINT SET</error>'); } $migrations[] = [ 'migration_status' => trim(strip_tags($status)), 'migration_id' => sprintf('%14.0f', $migration->getVersion()), 'migration_name' => $migration->getName() ]; unset($versions[$migration->getVersion()]); } if (count($versions)) { foreach ($versions as $missing => $version) { $output->writeln(sprintf(' <error>up</error> %14.0f %19s %19s <comment>%s</comment> <error>** MISSING **</error>', $missing, $version['start_time'], $version['end_time'], str_pad($version['migration_name'], $maxNameLength, ' '))); if ($version && $version['breakpoint']) { $output->writeln(' <error>BREAKPOINT SET</error>'); } } } } else { // there are no migrations $output->writeln(''); $output->writeln('There are no available migrations. Try creating one using the <info>create</info> command.'); } // write an empty line $output->writeln(''); if ($format !== null) { switch ($format) { case 'json': $output->writeln(json_encode([ 'pending_count' => count($this->getMigrations()), 'migrations' => $migrations ])); break; default: $output->writeln('<info>Unsupported format: ' . $format . '</info>'); } } } }