All Projects → drfraker → Snipe Migrations

drfraker / Snipe Migrations

Licence: mit
Blazing fast database migrations for Laravel tests.

Projects that are alternatives of or similar to Snipe Migrations

Laravel Migrations Organiser
A Laravel package to help organise migrations
Stars: ✭ 96 (-65.09%)
Mutual labels:  migrations, laravel
Laravel Relationships Data
Migrations, seeders and factories to get up and running with various relationship types data quickly
Stars: ✭ 27 (-90.18%)
Mutual labels:  migrations, laravel
Request Migrations
HTTP Request Migrations for API Versioning like Stripe
Stars: ✭ 149 (-45.82%)
Mutual labels:  migrations, laravel
Laravel Smart
Automatic Migrations, Validation and More
Stars: ✭ 48 (-82.55%)
Mutual labels:  migrations, laravel
Laravel Migrate Fresh
An artisan command to build up a database from scratch
Stars: ✭ 179 (-34.91%)
Mutual labels:  migrations, laravel
Eloquent Builder
Provides an advanced filter for Laravel or Lumen model.
Stars: ✭ 264 (-4%)
Mutual labels:  laravel
Laravel Eloquent Join
This package introduces the join magic for eloquent models and relations.
Stars: ✭ 270 (-1.82%)
Mutual labels:  laravel
Laravel Transactional Events
Transaction-aware Event Dispatcher for Laravel
Stars: ✭ 263 (-4.36%)
Mutual labels:  laravel
Formvuelar
Vue form components with server-side validation in mind
Stars: ✭ 263 (-4.36%)
Mutual labels:  laravel
Manaphp
ManaPHP Framework: Swoole+FPM
Stars: ✭ 271 (-1.45%)
Mutual labels:  laravel
Laravel Angular Cms
CMS built on Laravel, AngularJS and Material Design
Stars: ✭ 272 (-1.09%)
Mutual labels:  laravel
Eloquent Power Joins
The Laravel magic you know, now applied to joins.
Stars: ✭ 264 (-4%)
Mutual labels:  laravel
Cors
🔮Supported(Laravel/Lumen/PSR-15/Swoft/Slim/ThinkPHP) - PHP CORS (Cross-origin resource sharing) middleware.
Stars: ✭ 266 (-3.27%)
Mutual labels:  laravel
Laravel Gamp
📊 Laravel Google Analytics Measurement Protocol Package
Stars: ✭ 271 (-1.45%)
Mutual labels:  laravel
Html
Laravel package designed to generate common HTML components
Stars: ✭ 265 (-3.64%)
Mutual labels:  laravel
Laravel Nova Lang
🌌 Language files for Laravel Nova translated into 40+ languages. Feel free to submit your language or update an existing one!
Stars: ✭ 275 (+0%)
Mutual labels:  laravel
Laravel Slack
#️⃣ Slack notification for Laravel as it should be. Easy, fast, simple and highly testable.
Stars: ✭ 263 (-4.36%)
Mutual labels:  laravel
Blade Extensions
Laravel Blade extensions like $loop->odd/$loop->index in foreach, view blocks and partials, etc
Stars: ✭ 267 (-2.91%)
Mutual labels:  laravel
Laravel Aws Worker
Run Laravel (or Lumen) tasks and queue listeners inside of AWS Elastic Beanstalk workers
Stars: ✭ 272 (-1.09%)
Mutual labels:  laravel
Free Pmo
Project management software for freelancers or agencies, built with Laravel 5.
Stars: ✭ 264 (-4%)
Mutual labels:  laravel

build status StyleCI

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.

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

namespace Tests;

use Drfraker\SnipeMigrations\SnipeMigrations;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication, SnipeMigrations;
}
  1. By default, SnipeMigrations will store a .snipe file and the snipe_snapshot.sql file in /vendor/drfraker/snipe-migrations/snapshots. If you would like to change the location of the files follow the directions below to publish the snipe config file.

    • To publish the snipe config file, run php artisan vendor:publish and select snipe-config from the list.
  2. If the snipe_snapshot.sql file gets out of sync for any reason you can clear it by running php artisan snipe:clear. After running this command your original database migrations will run again creating a new snipe_snapshot.sql file.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].