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"
    ]
  }
}

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.

Did you find this post useful? Show some love!
Classic DEV Post from May 14

What is and is not "artificial intelligence"?

This term gets thrown around a lot, but what do people mean when they say this?...

READ POST
Follow @ben to see more of their posts in your feed.
dev.to is now open source!
View Announcement Post View GitHub Repo
David J Eddy
Automated testing nerd, CI / CD addict, PHP dork, Fox Mustang enthusiast, travel junkie.
More from @david_j_eddy
5 PHP Tools to make your life more enjoyable.
#php #tool #productivity #quality
Gatling, a load testing tool with a difference.
#automation #loadtesting #stresstesting
Trending on dev.to
PHP project scaffolding (kickstarting) tool
#showdev #php #productivity #automation
Ajax Live Search With PHP And MySQL
#php #ajax #html #mysql
Would a compiled version of PHP be great
#php
Logic of the JWT(JSON Web Tokens)
#webdev #php #java #beginners
Minimalist yet powerful PHP JWT library
#php #jwt #auth #showdev
Laravel Collections Higher Order Messages - Single Line Magic
#php #laravel #collections #higherordermessages
Don't return associative arrays!
#php #oop #beginners