Snipe Migrations Laravel Package

Snipe Migrations Laravel Package

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()
{
    parent::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!


Filed in: Laravel Packages / Migrations


Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Full Stack or Back-End Developer
Alexandria, VA; Tallahassee, FL; Orlando, FL
Marketing for Change
Senior Quality Assurance Engineer
Remote
Bisnow Media
Senior PHP/Laravel Developer: Your Dream Work Environment
Remote
iPhone Photography School
Senior Software Engineer
Remote or San Francisco
Curology
Laravel Developer
Las Vegas, NV
V Shred
R&D Developer
Denver, CO
booj
Full-Stack Developer
Paris, France
Wingly