muhammadhuzaifa / laravel-safe-migration
The package provide a safest way to run migration commands by generating backup of the database before running the actual migration command.
Requires
- php: ^8.1
- illuminate/contracts: ^10.0|^9.0
- spatie/laravel-backup: ^8.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2024-10-29 21:55:28 UTC
README
The package provides safest way to run migration by generating backup of the database each time before the monitorable command probably the migrate*
command is executed.
The laravel-safe-migration
package feature for generating backup is build on top of spatie/laravel-backup package.
Installation
You can install the package via composer:
composer require muhammadhuzaifa/laravel-safe-migration
You can publish the config file with:
php artisan vendor:publish --tag="safe-migration-config"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | Safe Migration Enabled |-------------------------------------------------------------------------- | | This value enable or disable the package functionality. | */ "safe_migration_enabled" => env('SAFE_MIGRATION_ENABLED', true), /* |-------------------------------------------------------------------------- | Commands To Monitor |-------------------------------------------------------------------------- | | This value determined which commands package should listen to | make database backup before executing it. | */ "commands_to_monitor" => [ "migrate", 'migrate:fresh', 'migrate:refresh', 'migrate:reset', 'migrate:rollback', ], /* |-------------------------------------------------------------------------- | Stop On Fail |-------------------------------------------------------------------------- | | This value determined whether the migration should continue or not if the | backup creation fail. | */ "stop_on_fail" => true, /* |-------------------------------------------------------------------------- | Filename |-------------------------------------------------------------------------- | | You can set the filename here. Timestamp and the extension will be appended | during the generation of the backup. | */ "filename" => "safe-migration", ];
Usage
Once the package is installed and monitorable commands are configured under the config/safe-migration.php
file. Each time you execute the monitorable command, the package will generate a backup file on the local
disk by default. The backups can be found at storage/app/Laravel
. You can customize the disks and other options using spatie config/backup.php
file.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.