定制 drfraker/snipe-migrations 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

drfraker/snipe-migrations

Composer 安装命令:

composer require drfraker/snipe-migrations

包简介

Blazing fast database migrations for Laravel tests.

README 文档

README

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

drfraker/snipe-migrations 适用场景与选型建议

drfraker/snipe-migrations 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 401.58k 次下载、GitHub Stars 达 289, 最近一次更新时间为 2019 年 02 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 drfraker/snipe-migrations 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 drfraker/snipe-migrations 我们能提供哪些服务?
定制开发 / 二次开发

基于 drfraker/snipe-migrations 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 401.58k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 289
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 289
  • Watchers: 4
  • Forks: 32
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-20