Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DbSchemaUpgradeCommand.php
Go to the documentation of this file.
1 <?php
8 
12 use Symfony\Component\Console\Input\InputInterface;
13 use Symfony\Component\Console\Input\InputOption;
14 use Symfony\Component\Console\Output\OutputInterface;
15 
20 {
26  private $installFactory;
27 
33  private $deploymentConfig;
34 
41  public function __construct(InstallerFactory $installFactory, DeploymentConfig $deploymentConfig)
42  {
43  $this->installFactory = $installFactory;
44  $this->deploymentConfig = $deploymentConfig;
45  parent::__construct();
46  }
47 
53  protected function configure()
54  {
55  $this
56  ->setName('setup:db-schema:upgrade')
57  ->setDefinition(
58  [
59  new InputOption(
61  null,
62  InputOption::VALUE_OPTIONAL,
63  'Allows to convert old scripts (InstallSchema, UpgradeSchema) to db_schema.xml format',
64  false
65  )
66  ]
67  )
68  ->setDescription('Installs and upgrades the DB schema');
69  parent::configure();
70  }
71 
75  protected function execute(InputInterface $input, OutputInterface $output)
76  {
77  if (!$this->deploymentConfig->isAvailable()) {
78  $output->writeln("<info>No information is available: the Magento application is not installed.</info>");
79  // we must have an exit code higher than zero to indicate something was wrong
80  return \Magento\Framework\Console\Cli::RETURN_FAILURE;
81  }
82  $installer = $this->installFactory->create(new ConsoleLogger($output));
83  $installer->installSchema($input->getOptions());
84  return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
85  }
86 }
__construct(InstallerFactory $installFactory, DeploymentConfig $deploymentConfig)
$deploymentConfig
execute(InputInterface $input, OutputInterface $output)