<p>You can use <a href="http://www.yiiframework.com/doc-2.0/guide-db-migrations.html#applying-migrations" rel="noreferrer">Yii's migrate console command</a>.</p>

<p>Triggered in Craft 3 via <code>craft migrate --type=app</code>.</p>

CC BY-SA 3.0
2017-10-13T10:16:25.397Z
And just to make sure: nothing else is done in this (normally) manual step than applying the Yii migrations?
Matthias Redl-Mann
CC BY-SA 3.0
2017-10-13T22:42:15.847Z
Correct... the updater uses the same logic
Brad Bell
CC BY-SA 3.0
2017-11-13T09:19:16.710Z
I just had the change to try it, but it does not work. The website itself currently gives me a 503 "Service unavailable", under /admin/ I get "To complete the update, some changes must be made to your database."
Matthias Redl-Mann
CC BY-SA 3.0
2017-11-13T09:57:33.410Z
...
But the manual "craft migrate" still tells me "No new migrations found. Your system is up-to-date."

I also tried setting the migration path via "./craft migrate --migrationPath=@vendor/craftcms/cms/src/migrations --interactive=0". Still "no new migrations found":

Any ideas?
Matthias Redl-Mann
CC BY-SA 3.0
2017-11-13T18:04:14.970Z
My bad... by default it queries for site migrations.  Add the `--type=app` to tell it to look at Craft migrations.
Brad Bell
CC BY-SA 3.0
2017-11-14T10:24:03.580Z
OK, Migrations work that way, but the 503 does not get removed (although it does not seem to be caused by the "maintenance" column in the "info" table (which is 0). You still need to press the button under /admin/ (wich will also causes an update to the version column in the "info" table to the current version). So pressing the button in the backend seems to do more than the migrations. Could you provide a command for the whole thing? Because an automation to that is really valuable.
Matthias Redl-Mann
CC BY-SA 3.0
2017-11-14T21:55:36.123Z
Agree, it'd be useful. Looks like there is already an FR for this: https://github.com/craftcms/cms/issues/1907
Brad Bell
CC BY-SA 3.0
2017-10-11T17:21:31.320Z
2017-11-13T18:03:44.920Z
2017-11-13T18:03:44.920Z
Brad Bell
<p>Is there any craft command command (shell) which can be used to perform the database updates necessary after a CMS update? (e.g. Craft3 beta-28 to beta29 or multi version updates)</p>

<p>Background: We are deploying our projects with Jenkins and I would want Jenkins to call such a command after each deployment (or after each CMS update). Going to the /admin/ Panel manually to be told that the database needs to be upgraded is not ideal.</p>

<database><craft3><migration><updates>
Craft 3: Update database after CMS upgrade via console command
# Craft 3: Update database after CMS upgrade via console command

(Asked by: username_0 on 2017-10-11)

Is there any craft command command (shell) which can be used to perform the database updates necessary after a CMS update? (e.g. Craft3 beta-28 to beta29 or multi version updates)

Background: We are deploying our projects with Jenkins and I would want Jenkins to call such a command after each deployment (or after each CMS update). Going to the /admin/ Panel manually to be told that the database needs to be upgraded is not ideal.

**Tags:** database, craft3, migration, updates


---

## 1 answers

### Answer by username_1 on 2017-10-11. Score: 7 | Accepted answer

You can use [Yii's migrate console command](http://www.yiiframework.com/doc-2.0/guide-db-migrations.html#applying-migrations).

Triggered in Craft 3 via `craft migrate --type=app`.

> **Comments:**
> **username_0**: And just to make sure: nothing else is done in this (normally) manual step than applying the Yii migrations?  
> **username_1**: Correct... the updater uses the same logic  
> **username_0**: I just had the change to try it, but it does not work. The website itself currently gives me a 503 "Service unavailable", under /admin/ I get "To complete the update, some changes must be made to your database."  
> **username_0**: ... But the manual "craft migrate" still tells me "No new migrations found. Your system is up-to-date."  I also tried setting the migration path via "./craft migrate --migrationPath=@vendor/craftcms/cms/src/migrations --interactive=0". Still "no new migrations found":  Any ideas?  
> **username_1**: My bad... by default it queries for site migrations.  Add the `--type=app` to tell it to look at Craft migrations.  
> **username_0**: OK, Migrations work that way, but the 503 does not get removed (although it does not seem to be caused by the "maintenance" column in the "info" table (which is 0). You still need to press the button under /admin/ (wich will also causes an update to the version column in the "info" table to the current version). So pressing the button in the backend seems to do more than the migrations. Could you provide a command for the whole thing? Because an automation to that is really valuable.  
> **username_1**: Agree, it'd be useful. Looks like there is already an FR for this: https://github.com/craftcms/cms/issues/1907  

---

