smartlaravel / safe-migrate
Adds a prompt the the migrate command when connected to any non local database.
This package is auto-updated.
Last update: 2024-09-25 06:02:01 UTC
README
This package extends the migration and seed commands. When you run
php artisan migrate
and yourDB_HOST
setting is not set to127.0.0.1
orlocalhost
you will receive a safety confirmation asking you to confirm running the migration. This package was created out of an issue where I was connecting to different database connections to run commands remotely, I would forget to update the database connection and run a destructive migration on production. Luckily we backed our data up and no developers were harmed.
To install:
composer require smartlaravel/safe-migrate
To test:
You can set your hosts file to aim a random address to localhost, such as
12.23.34.45
. Then set your Laravel .env file to useDB_HOST=12.23.34.45
. Runphp artisan migrate
,php artisan migrate:fresh
, etc. and you should see a prompt warning you that your database connection is not local.