O'Reilly logo

Learning Laravel's Eloquent by Francesco Malatesta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Database versioning with the migrations system

Until this point, we worked with the Schema class using some simple routes. Quite easy, but it's not a very good practice. You know: the single responsibility principle is not just a bedtime story.

Also, it's not just about the code: the database too should have a fully functional version control system in order to keep track of all the updates and facilitate a new member in your team.

Well, the migrations system is here to help. You can see it as a version control system for your database, which is made up of many files. Every single one of these files is a class with the two methods: up() and down(). In the up() method, you will put all of your database construction logic. In the down() method, instead, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required