I'm using migrations for managing db changes in development and applying them to production.
But once I've run the migrations in production I delete them as running php artisan migrate:refresh
could easily wipe out a lot of useful production data.
I wonder if what I'm doing is something people normally do or if I should manage dev to production workflow differently. What are best practices to this?
As of Laravel 4.2, when you run php artisan migrate
in production - it will give you a clear warning that you are running on the production server, and prompt you are you sure?
in the console. That way to can be careful that you only ever run the migrate command correctly.
The other option is using something like Laravel Forge or Laravel Envoy, which have deployment scripts, so it automatically does something like
php artisan down
git pull
composer install
php artisan migrate
composer dump
php artisan optimize
php artisan up
So that the workflow is always correct.