3 ms·
Hmm I think this might be the missing piece that opens up the possibility for a really seamless integration with the built-in migration system for Laravel (or R
by aarondf 4y ago
Hmm I think this might be the missing piece that opens up the possibility for a really seamless integration with the built-in migration system for Laravel (or Rails). I know don't what all is available via CLI or API, but let's just assume it'll all be there at some point.
Here's my super hand-wavvy idea on how the workflow might go:
Step one would be to run migrations with a new `stage` flag:
php artisan migrate --stage
This command would do a few things:
- Calculate a stable hash of yet-to-be-applied Laravel migrations (e.g. e8f8e19a)
- Create the branch on PlanetScale, using the hash for the branch name (e.g. prod-e8f8e19a)
- Deploy the changes but not apply them yet.
After the changes have been made on the PS side (which could take a long time, or no time at all!) you could run:
php artisan migrate --apply
That command would calculate the hash again (since it's stable) and apply the changes, merging them all into prod.
You could probably run the --stage command on every deploy and just noop it if nothing changes, and then run the --apply command manually when you're ready. Of course you still need to be cognizant of code changes that rely on the new / old schema, but that's true with every staged deploy.
And if you want to get really wacky, you might be able to roll it all into one command with a --wait param. I can imagine running
php artisan migrate --wait=600
Now it will do it will deploy & apply in one step, provided it can finish in less than 5 minutes.
Tbh I may just have to make this package... just to see if it could work.