Snipe Migrations Laravel Package


February 21st, 2019

Snipe Migrations is a Laravel package by Dustin Fraker for “blazing fast” database migrations for tests:

The package takes a snapshot of your mysql database and imports the schema to your test database rather than running all of your migrations when the test suite starts up.

On projects with many migration files, Snipe Migrations may have a huge speed improvement over migrating the database during setup.

It works by adding this method to your base test class that your other tests extend:

public function setUpTraits()

    $uses = array_flip(class_uses_recursive(static::class));

    if (isset($uses[DatabaseTransactions::class])) {
        (new Snipe())->importSnapshot();

After you’ve added the setUpTraits() method, you then use it by importing the use DatabaseTransactions trait in your tests.

Learn More

In his writeup, Dustin talks about his reasons for creating Snipe Migrations. You should check out his full post about building the package, including a video at the end which goes over his use-case and how to set up the package.

You can learn more about the Snipe Migrations package at drfraker/snipe-migrations. To learn how to install and use the package, check out the Snipe Migration README file.

Congratulations on your first open-source Laravel package Dustin!

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.