承接 marcelohoffmeister/migrator 相关项目开发

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

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

marcelohoffmeister/migrator

Composer 安装命令:

composer require marcelohoffmeister/migrator

包简介

Namespaced Migrations for Laravel 6.0+

README 文档

README

Latest Stable Version Total Downloads Monthly Downloads License

This package is a customized version of Laravel's default database migrator, it was designed to register migrations on services providers and support namespacing as well.

There is no timestamp previews since the run order is based on how you register the migrations.

Warning

This Package Supports Laravel starting on 5.2 up to the latest stable version.

Installing

In order to install Migrator, run the following command into your Laravel 6.0+ project:

composer require marcelohoffmeister/migrator

After installing the Package, you can now register it's provider into your config/app.php file:

'providers' => [
    // other providers omitted.
  Migrator\MigrationServiceProvider::class,
]

And publish configuration: with

php artisan vendor:publish --provider="Migrator\MigrationServiceProvider"

Usage

As the default Laravel migrator, this one has all the original commands, to list the available options, you can see all the available options using php artisan command.

migrator            Run the database migrations
migrator:fresh      Drop all tables and re-run all migrations
migrator:install    Create the migration repository
migrator:make       Create a new migration file
migrator:refresh    Reset and re-run all migrations
migrator:reset      Rollback all database migrations
migrator:rollback   Rollback the last database migration
migrator:status     Show the status of each migration

Creating Migrations

In order to generate an empty migration, please provide the migrator with the full qualified class name, as the example.

php artisan migrator:make 'MyApp\MyModule\Database\Migrations\CreateOrdersTable' --create=orders

This will create a migration class into the right directory, the resulting file is slightly different from the default Laravel generated:

<?php

namespace MyApp\MyModule\Database\Migrations;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration
{
    /**
 * @var \Illuminate\Database\Schema\Builder
 */  protected $schema;

    /**
 * Migration constructor. */  public function __construct()
     {
         $this->schema = app('db')->connection()->getSchemaBuilder();
     }

    /**
 * Run the migrations. * * @return void
 */  public function up()
    {
        $this->schema->create('orders', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
        });
    }

    /**
 * Reverse the migrations. * * @return void
 */  public function down()
    {
        $this->schema->drop('orders');
    }
}

To declare your table fields, just follow the usual schema build practices, this package don't make anything different there.

As the normal migrator, you can pass the option --table instead of --create in order to generate a update migration instead of a create one. Also, you can create a empty migration not passing any of those options.

In this fork, you can pass the option --path for the fresh command. This execute the command in the specific path.

Registering migrations.

Inside any service provider of your choice (usually on the same namespace that you're storing the migrations), you easily register the migrations using the Migrator\MigratorTrait:

<?php

namespace MyApp\MyModule\Providers;
  
use Illuminate\Support\ServiceProvider;
use Migrator\MigratorTrait;
use MyApp\MyModule\Database\Migrations\CreateOrdersTable;
use MyApp\MyModule\Database\Migrations\CreateProductsTable;

class MyModuleServiceProvider extends ServiceProvider
{
    use MigratorTrait;

    public function register()
    {
        $this->migrations([
            CreateOrdersTable::class,
            CreateProductsTable::class,
        ]);
    }
}

marcelohoffmeister/migrator 适用场景与选型建议

marcelohoffmeister/migrator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 marcelohoffmeister/migrator 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-29