trevorpan
2 months ago
51
4
Forge

Forge: script for adding column to production database table

Posted 2 months ago by trevorpan

Was reading this post below and feel I have a good understanding of the process of creating a new migration which then adds a column to an existing table. I know I'll have to test the nullable or default values for previous users, e.g. to ensure there are no errors.

https://laracasts.com/discuss/channels/laravel/what-is-the-typical-process-to-add-a-field-to-a-production-database-without-loosing-existing-data

This doc: https://laravel.com/docs/5.8/migrations#columns states you need to add this dependency composer require doctrine/dbal. I've done that locally.

When I get ready to push this to production does the below script cover this dbal?

It seems like a yes, as it's in the composer.json which would be pushed to master, but it's not something I want to get wrong.

cd /home/forge/bidbird.co
git pull origin master
composer install --no-interaction --prefer-dist --optimize-autoloader
php artisan config:cache -q --no-interaction
php artisan route:cache
npm run production
echo "" | sudo -S service php7.1-fpm reload

if [ -f artisan ]
then
    php artisan migrate --force
fi

Thank you for any tips..

Please sign in or create an account to participate in this conversation.