PHPackages                             drfraker/snipe-migrations - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. drfraker/snipe-migrations

ActiveLibrary[Testing &amp; Quality](/categories/testing)

drfraker/snipe-migrations
=========================

Blazing fast database migrations for Laravel tests.

v1.4.0(5y ago)289400.5k↓29.5%32[8 issues](https://github.com/drfraker/snipe-migrations/issues)[3 PRs](https://github.com/drfraker/snipe-migrations/pulls)MITPHPPHP ^7.1|^8.0CI failing

Since Feb 20Pushed 3y ago4 watchersCompare

[ Source](https://github.com/drfraker/snipe-migrations)[ Packagist](https://packagist.org/packages/drfraker/snipe-migrations)[ RSS](/packages/drfraker-snipe-migrations/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (3)Versions (15)Used By (0)

[![build status](https://camo.githubusercontent.com/811cc440dfbe009f88e89e0ea81021897c7a405eec60f35f7aec6740502bad35/68747470733a2f2f7472617669732d63692e636f6d2f64726672616b65722f736e6970652d6d6967726174696f6e732e7376673f6272616e63683d6d6173746572 "build status")](https://camo.githubusercontent.com/811cc440dfbe009f88e89e0ea81021897c7a405eec60f35f7aec6740502bad35/68747470733a2f2f7472617669732d63692e636f6d2f64726672616b65722f736e6970652d6d6967726174696f6e732e7376673f6272616e63683d6d6173746572)[![StyleCI](https://camo.githubusercontent.com/f0d4683344d9981fbb5b6f70c33f0c1c4a9f621ec821251b10edeac7d1fed0ae/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137313531313030362f736869656c643f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/f0d4683344d9981fbb5b6f70c33f0c1c4a9f621ec821251b10edeac7d1fed0ae/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137313531313030362f736869656c643f6272616e63683d6d6173746572)

Snipe Migrations
================

[](#snipe-migrations)

Blazing fast database migrations for Laravel 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.

If you have a project with many migration files, this process can provide you with a massive speed improvement when initializing your test suite. This package can be used as a replacement for the RefreshDatabase trait that is provided out of the box with Laravel.

As an example, we tested this on an application that takes about 4 seconds to run all migrations with RefreshDatabase. Using SnipeMigrations the tests start up in 200 ms.

Requirements
------------

[](#requirements)

1. Laravel &gt;= 5.5
2. PHP &gt;= 7.1
3. MySql or MariaDb, with separate database for testing.
    - For example if you have a development database for your application called `amazingapp`you would create a test database called `amazingapp_test` and add the details of the database in your phpunit.xml file. `amazingapp_test` is the database that Snipe will keep in sync for you.

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

[](#installation)

Require the package using composer.

```
composer require --dev drfraker/snipe-migrations
```

Usage
-----

[](#usage)

**After you've installed the package via composer**

1. Add the `SnipeMigrations` trait to your `tests/TestCase` file. Don't forget to import the class at the top of the file. Once you have added the `SnipeMigrations` trait, simply use the RefreshDatabase trait in any tests in which you wish to use database access, and Snipe will handle the rest for you.

When you're done, your `tests/TestCase.php` file should look like this.

```
