When does command setup:upgrade run after the code is deployed to production environment Is there any option to enable this configuration, and schedule when to run this command or it will run automatically when my code is deployed

3 Answers 3


In Magento Cloud its run automatically like Yigen said, but sometimes is delay after deploy.

So if you want to update database now just run this command on server. Its same like in: vendor/magento/ece-tools/src/Process/Deploy/InstallUpdate/Update/Setup.php

php ./bin/magento setup:upgrade --keep-generated --ansi --no-interaction

Files are read only but this command in not regenerating any files.


Im afraid you cant do that on cloud. The deployment is automatic by ece-tools package . [Cloud Info]

enter image description here ece-tools package

The ece-tools package is a scalable deployment tool that simplifies the Cloud upgrade process. In 2018, we deprecated the magento-cloud-configuration and ece-patches packages in favor of providing a single package. We encourage all customers to upgrade to use ece-tools as soon as possible to benefit from the package features, such as commands to create a backup of the database, apply custom patches, and verify environment configuration.

More info for ece-tools Link

If you do some findings in your repo . Open .magento.app.yaml and you will see this

    # We run build hooks before your application has been packaged.
    build: |
        php ./vendor/bin/ece-tools build
    # We run deploy hook after your application has been deployed and started.
    deploy: |
        php ./vendor/bin/ece-tools deploy
    # We run post deploy hook to clean and warm the cache. Available with ECE-Tools 2002.0.10.
    post_deploy: |
        php ./vendor/bin/ece-tools post-deploy

The execution function of setup upgrade is in this path :

public function execute()

        try {
            $verbosityLevel = $this->stageConfig->get(DeployInterface::VAR_VERBOSE_COMMANDS);

            $this->logger->info('Running setup upgrade.');

                '/bin/bash -c "set -o pipefail; %s | tee -a %s"',
                'php ./bin/magento setup:upgrade --keep-generated --ansi --no-interaction ' . $verbosityLevel,
        } catch (\RuntimeException $e) {
            //Rollback required by database
            throw new \RuntimeException($e->getMessage(), 6);

  • So is it the default behaviour or do I need to configure something in magento.app.yml manually
    – summu
    Commented Feb 7, 2019 at 15:17
  • It is the default behaviour :( , not sure talking with their support if they can arrange smth about you, Commented Feb 7, 2019 at 15:31

No, commands never run automatically.

Only crons run automatically and repeated if configured correctly.

setup:upgrade should not be a cron!!!!

You have to call it manually within your deployment.

  • Its in cloud, magento2 cloud
    – summu
    Commented Feb 7, 2019 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.