mombuyish/laravel-batch-migrations

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (0.1.0) of this package.

Batching migrate schema for laravel

0.1.0 2017-03-14 02:33 UTC

This package is auto-updated.

Last update: 2020-02-08 15:48:18 UTC


README

it can batch to the database migration.

Required:

  • laravel 5.3 or later.
  • php 7 or later.

Situation

Sometimes, your project's migration want to separate folders, but you need to add option --path=database/migrations/someone/ or others, that's good but I want to more automatic. Imagine one command to do all migration or rollback, that's it.

For example, I have 2 directories in database/migrations:

  database/
     migrations/
        testing1/
            create_posts_table.php
            create_comment_table.php
        testing2/
            create_articles_table.php
            create_messages_table.php

And then you run php arisan migrate:batch it will do all migration done.

Installation

As others package, use composer install this package. For example:

$ composer require mombuyish/laravel-batch-migrations

Secondly, you need to register service provider in config/app.php.

    'providers' => [
    ...
    /*
     * Package Service Providers...
     */
     Mombuyish\BatchMigration\BatchMigrationServiceProvider::class,
    ...

Thirdly, Going to app/Console/Kernel.php, adding console command.

protected $commands = [
        \Mombuyish\BatchMigration\Commands\BatchMigration::class,
        \Mombuyish\BatchMigration\Commands\RollbackBatchedMigration::class
    ];

Fourthly, publish config.

$ php artisan vendor:publish --provider="Mombuyish\BatchMigration\BatchMigrationServiceProvider"

You can do configure on config batch-migration.php

return [

    /**
     * Accessible paths.
     */
    'path' => 'database/migrations',

];

Finally, you can checkout $ php artisan and you can see 2 commands.

  migrate:batch           Run the database migrations (including depth dictionaries)
  migrate:batch-rollback  Rollback the last database migration (including depth directories)
  • When you run php artisan migrate:batch, it will do all migrate in path.
  • When you run php artisan migrate:batch-rollback, it will rollback your migrate:batch done.

Supported --force

Notice

When you run rollback, maybe it got errors, For know, you need specific directory. php artisan migrate:rollback --path=database/migrations/someone.