Skip to content
This repository has been archived by the owner. It is now read-only.
Run batch to the database migration. Including depth dictionaries.
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
src
README.md
composer.json

README.md

Laravel Batch Migration

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.

You can’t perform that action at this time.