Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drfraker/snipe-migrations
Blazing fast database migrations for Laravel tests.
https://github.com/drfraker/snipe-migrations
laravel migrations testing
Last synced: 2 months ago
JSON representation
Blazing fast database migrations for Laravel tests.
- Host: GitHub
- URL: https://github.com/drfraker/snipe-migrations
- Owner: drfraker
- License: mit
- Created: 2019-02-19T16:40:09.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-18T17:46:30.000Z (over 1 year ago)
- Last Synced: 2024-09-21T11:41:32.721Z (4 months ago)
- Topics: laravel, migrations, testing
- Language: PHP
- Homepage:
- Size: 53.7 KB
- Stars: 287
- Watchers: 5
- Forks: 30
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-blazingly-fast - snipe-migrations - Blazing fast database migrations for Laravel tests. (PHP)
README
![build status](https://travis-ci.com/drfraker/snipe-migrations.svg?branch=master "build status")
![StyleCI](https://github.styleci.io/repos/171511006/shield?branch=master)# 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
1. Laravel >= 5.5
2. PHP >= 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
Require the package using composer.
```bash
composer require --dev drfraker/snipe-migrations
```## 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.
```php