PHPackages                             orottier/laravel-migration-squasher - 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. [Framework](/categories/framework)
4. /
5. orottier/laravel-migration-squasher

ActiveLibrary[Framework](/categories/framework)

orottier/laravel-migration-squasher
===================================

Aggregate your incremental Laravel migration files into single migration for each table. This eliminates all alter columns and makes testing via sqlite a possibility.

0.1(9y ago)6952MITPHP

Since May 18Pushed 9y ago1 watchersCompare

[ Source](https://github.com/orottier/laravel-migration-squasher)[ Packagist](https://packagist.org/packages/orottier/laravel-migration-squasher)[ RSS](/packages/orottier-laravel-migration-squasher/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Aggregate your incremental Laravel migration files into single migration for each table. This can be beneficial when needing to compress large migration sets into a single migration for each table.

This package also eliminates all alter columns since all migrations are aggregated into a single file making testing via sqlite a possibility.

To install simply require this forked package:

```
"orottier/laravel-migration-squasher": "~0.1"

```

Then, add the service provider to your config/app.php to enable artisan functionality:

```
Cytracom\Squasher\SquasherServiceProvider::class

```

NOTE: this is not required if you do not wish to have the commandline interface. If you want to use the squasher just for testing, then you can ignore this service provider, and call the squasher directly. This way, the squasher can be in your require-dev and not be a part of your production stack.

Commandline usage:

```
php artisan migrate:squash [-p|--path[="..."]] [-o|--output[="..."]] [-mv|--move-to[="..."]]

Options:
 --path (-p)           The path to the migrations folder (default: "database/migrations")
 --output (-o)         The path to the output folder of squashes (default: "tests/migrations")
 --move-to (-mv)       The path where old migrations will be moved. (default: "database/migrations")

```

Usage in php:

```
$squasher = new \Cytracom\Squasher\MigrationSquasher($pathToMigrations, $outputForSquashedMigrations [, $moveOldToThisPath = null]);
$squasher->squash();
```

The squasher does not currently support composite keys, or indexes. If you find anything else I missed, please raise an issue! Or, even better, attempt to integrate it!

The migration squasher will take several migrations and create a single, final migration that reflects what the database schema should be after all migrations have run.

Keep in mind that the squasher was made for testing, not for incremental database changes. Using the squasher will drop any non-migration related functionality in your code. The goal is to get rid of all alter columns, to enable sqlite testing.

The table squasher can handle simple migration statements, written in a normal, not insane way. Like this:

```
Schema::create('my_table', function (Blueprint $table) {
    $table->integer("my_int",10)->unsigned()->unique();
    $table->increments("id");
    $table->string("test",255);
    $table->myEnum("oldArrayInit", array("val1","val2"));
    $table->myEnum("newArrayInit", ["val1","val2"]);

    DB::update('ALTER TABLE `my_table` MODIFY COLUMN `test` blob(500);');
    //etc;
});
```

This also works for dropping and modifying schemas. For a more detailed view on what it can handle, look at the sample test data in src/tests/data/MigrationTestData.php

The table squasher will NOT handle things like

```
$myStringColumns = ["col1","col2","col3"];
foreach($myStringColumns as $column){
    $table->string($column);
}
```

And it never ever will. Migrations shouldn't be written this way, and writing a php parser in php is no small task.

Here is how you can use this for your tests

While setting up the test case, we run

```
recursiveDelete(base_path('tests/migrations'));
$squash = new \Cytracom\Squasher\MigrationSquasher("database/migrations", "tests/migrations");
$squash->squash();
\Artisan::call('migrate', ['--path' => 'tests/migrations']);

/**
 * Delete a file or recursively delete a directory
 *
 * @param string $str Path to file or directory
 * @return bool
 */
function recursiveDelete($str){
    if(is_file($str)){
        return @unlink($str);
    }
    elseif(is_dir($str)){
        $scan = glob(rtrim($str,'/').'/*');
        foreach($scan as $index=>$path){
            recursiveDelete($path);
        }
        return @rmdir($str);
    }
}
```

We delete all of the migrations before squashing again, to get rid of old squashed migrations that may be there.

Again, please raise an issue if you find one, and feel free to make pull requests for review! Our goal is to make testing with sqlite much more of a possibility, to enable fast testing. Help from the community is always appreciated.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86% 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

Unknown

Total

1

Last Release

3645d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/955189db975f4072979349a76e9d81aa01b7fe354e6a78dc527efd4301b39b53?d=identicon)[otto](/maintainers/otto)

---

Top Contributors

[![Jacoby6000](https://avatars.githubusercontent.com/u/2672832?v=4)](https://github.com/Jacoby6000 "Jacoby6000 (49 commits)")[![orottier](https://avatars.githubusercontent.com/u/5442615?v=4)](https://github.com/orottier "orottier (7 commits)")[![zconkle](https://avatars.githubusercontent.com/u/3064703?v=4)](https://github.com/zconkle "zconkle (1 commits)")

---

Tags

testingframeworklaravelmigrationsqlitemigrationsmigratesquash

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/orottier-laravel-migration-squasher/health.svg)

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

###  Alternatives

[pestphp/pest-plugin-laravel

The Pest Laravel Plugin

22044.1M8.0k](/packages/pestphp-pest-plugin-laravel)[codewithdennis/larament

Larament is a time-saving starter kit to quickly launch Laravel 13.x projects. It includes FilamentPHP 5.x pre-installed and configured, along with additional tools and features to streamline your development workflow.

3691.5k](/packages/codewithdennis-larament)[graham-campbell/testbench-core

TestBench Core Provides Some Testing Functionality For Laravel

16672.7k13](/packages/graham-campbell-testbench-core)[kompo/kompo

Laravel &amp; Vue.js FullStack Components for Rapid Application Development

11812.4k21](/packages/kompo-kompo)

PHPackages © 2026

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