PHPackages                             muhammadhuzaifa/laravel-safe-migration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. muhammadhuzaifa/laravel-safe-migration

ActiveLibrary[Database &amp; ORM](/categories/database)

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.

v1.1.0(3y ago)1149[1 PRs](https://github.com/huzaifaarain/laravel-safe-migration/pulls)MITPHPPHP ^8.1

Since May 1Pushed 3y ago1 watchersCompare

[ Source](https://github.com/huzaifaarain/laravel-safe-migration)[ Packagist](https://packagist.org/packages/muhammadhuzaifa/laravel-safe-migration)[ Docs](https://github.com/huzaifaarain/laravel-safe-migration)[ RSS](/packages/muhammadhuzaifa-laravel-safe-migration/feed)WikiDiscussions main Synced yesterday

READMEChangelog (3)Dependencies (13)Versions (5)Used By (0)

Laravel Safe Migrations
=======================

[](#laravel-safe-migrations)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f26a8f7852963e38b4e9b27090b102e8a28ea34b2220d4d68888c21accc6b7ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7568616d6d616468757a616966612f6c61726176656c2d736166652d6d6967726174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muhammadhuzaifa/laravel-safe-migration)[![Total Downloads](https://camo.githubusercontent.com/f8dfae0961f1de73db1fe3c068ff7ec99af8e690eba6c51a16355c74056abe6c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7568616d6d616468757a616966612f6c61726176656c2d736166652d6d6967726174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/muhammadhuzaifa/laravel-safe-migration)

- [Laravel Safe Migrations](#laravel-safe-migrations)
    - [Installation](#installation)
    - [Usage](#usage)
    - [Changelog](#changelog)
    - [Credits](#credits)
    - [License](#license)

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](https://github.com/spatie/laravel-backup) package.

Installation
------------

[](#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
-----

[](#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
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Muhammad Huzaifa](https://github.com/huzaifaarain)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

1158d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fc1c37056f779b40cadc67a30b0159e53f468e01bceb5a4f805b7264539cf973?d=identicon)[muhammadhuzaifa](/maintainers/muhammadhuzaifa)

---

Top Contributors

[![huzaifaarain](https://avatars.githubusercontent.com/u/8613679?v=4)](https://github.com/huzaifaarain "huzaifaarain (12 commits)")

---

Tags

laravelmigrationphplaravelMuhammadHuzaifalaravel-safe-migration

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/muhammadhuzaifa-laravel-safe-migration/health.svg)

```
[![Health](https://phpackages.com/badges/muhammadhuzaifa-laravel-safe-migration/health.svg)](https://phpackages.com/packages/muhammadhuzaifa-laravel-safe-migration)
```

###  Alternatives

[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

213421.0k2](/packages/wnx-laravel-backup-restore)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17558.6k](/packages/lacodix-laravel-model-filter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
