DEV Community

David J Eddy
David J Eddy

Posted on

4 2

Never run a migration again using PHPs Composer

Every get tired of running database migrations after updating your application? Let composer do it for you! In this example we will use Yii2's migration command as an example:

{
  "name": "Application Name",
  "description": "Some desciption text",
  ...
  "scripts": {
    "post-install-cmd": [
      "php console/yii app/setup --interactive=0"
    ],
    "post-update-cmd": [
      "php console/yii app/setup --interactive=0"
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

If you write your migrations in an atomic fashion (once changed, do not over write) the migration can be run over and over without causing errors. You can even run multiple commands after a composer action via the command hooks.

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more