PlanetScale Database Migrations for Laravel
Published on by Paul Redmond
This community PlanetScale package for Laravel adds an artisan pscale:migrate
command to your Laravel applications. This command helps you manage database migrations using the PlanetScale API, a process which varies slightly from using the built-in migrate
command.
During a deployment, you'd run the following command instead of migrate
which does everything necessary to update your database's schema:
php artisan pscale:migrate
Why is this needed?
You might wonder why this command is needed instead of directly using the migrate
command.
According to the package's readme, PlantScale handles migrations in a different way that you'd typically see with databases:
PlanetScale has alot of advantages when using it as your application's production database. However it handles your database and schema migrations in a somewhat unusual way.
It uses branches for your database. A branch can be production or development...
This package uses PlanetScale's Public API to automate the process of creating a new development branch, connecting your app to the development branch, running your Laravel migrations on the development branch, merging that back into your production branch, and deleting the development branch.
To get started with this package, check out the package setup instructions on GitHub at x7media/laravel-planetscale.
Related: Speaking of PlanetScale and databases, Aaron Francis published MySQL for Developers. We'd highly recommend you check that out to improve your database skills.