承接 netcreaties/laravel-synchronize 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

netcreaties/laravel-synchronize

最新稳定版本:v2.0.2

Composer 安装命令:

composer require netcreaties/laravel-synchronize

包简介

Laravel Synchronizations will enable you to create one time synchronizations and prevent creating commands you only use once

README 文档

README

Build Status Downloads Code Intelligence Status Scrutinizer Code Quality StyleCi

This package gives you the ability to create synchronization files and prevent you from having to write one time use commands when you've got for example: A database structure change that will require you to synchronize the old structure data with the new structure.

Documentation

Installation

The best way to install this package is through your terminal via Composer.

Run the following command from your projects root

composer require netcreaties/laravel-synchronize

Laravel 5.5+

This package supports package discovery.

Execute migrations

Getting started

Publish config (optional)

Publishing the config will enable you to overwrite some of the settings this package uses. For example you can define where synchronization files should be stored.

php artisan vendor:publish --provider="LaravelSynchronize\Providers\ServiceProvider" --tag="config"

Publish migration

php artisan vendor:publish --provider="LaravelSynchronize\Providers\ServiceProvider" --tag="migrations"

Execute migrations

php artisan migrate

Usage

Laravel Synchronize executes synchronizations that have the same class name as the migration class name, but with a Synchronization suffix, when executing migrations. This is the advised usage to ensure database integrity, but it is possible to execute synchronizations on their own (see section Synchronize command).

Make command

php artisan make:synchronization {name}

Creates the synchronization file at database/synchronizations

Synchronize command

php artisan synchronize

Using --class and --force

It can happen you need a synchronization before you can perform a migration. Using --class and --force can help you achieving that goal.

All you need to do is using the Laravel 5.8.16+ Migration events.

Example:

    public function __construct()
    {
        Event::listen(MigrationStarted::class, function (MigrationStarted $listener) {
            if ($listener->migration instanceof $this && $listener->method === 'up') {
                Artisan::call('synchronize --class=TestASync --force');
                echo Artisan::output();
            }
        });
    }

--force

--force will execute the synchronization even when it already has been run. Use with caution.

统计信息

  • 总下载量: 10.19k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

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