2017 © Pedro Peláez
 

library laravel-specific-migrate

Specific File Migrations for Laravel 5

image

igonics/laravel-specific-migrate

Specific File Migrations for Laravel 5

  • Wednesday, March 1, 2017
  • by ggordon
  • Repository
  • 1 Watchers
  • 1 Stars
  • 173 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel Specific File Migrator

Migrate Specific Migrations, (*1)

Installation

Step 1. Install using composer, (*2)

composer require igonics/laravel-specific-migrate

Step 2. Add Service Provider to config/app.php, (*3)

return [
     ...
     "providers":[
        ...
        IGonics\Migrations\Providers\SpecificMigratorServiceProvider::class,
     ]
];

Usage

Migrating specific files, (*4)

php artisan migrate:specific --files="filename_1, filename_2"

Rollback specific files, (*5)

php artisan migrate:specific-rollback --files="filename_1, filename_2"

Using the specific migrator

Migrating specific files, (*6)

class MigrateComponent extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $name = 'component:migrate';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Migrate Component Schema';

    /**
     * Create a new command instance.
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $relativePath = database_path('migrations');
        $path = __DIR__.$relativePath;
        //var_dump($path);
        $files = array_filter(scandir($path), function ($file) {
            return preg_match("/\.php/", $file) == 1;
        });
        $files = array_map(function ($file) use ($path) {
            return str_replace([$path, '.php'], '', $file);
        }, $files);
        //var_dump($files);

        $this->call('migrate:specific', [
            '--force' => true,
            '--path' => str_replace(app_path(), '', $path),
            '--files' => implode(',', $files),
        ]);
    }
}

Rolling back specific files, (*7)

class RollbackComponent extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $name = 'component:rollback';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Rollback Component Schema';

    /**
     * Create a new command instance.
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $relativePath = database_path('migrations');
        $path = __DIR__.$relativePath;
        //var_dump($path);
        $files = array_filter(scandir($path), function ($file) {
            return preg_match("/\.php/", $file) == 1;
        });
        $files = array_map(function ($file) use ($path) {
            return str_replace([$path, '.php'], '', $file);
        }, $files);
        //var_dump($files);

        $this->call('migrate:specific-rollback', [
            '--force' => true,
            '--path' => str_replace(app_path(), '', $path),
            '--files' => implode(',', $files),
        ]);
    }
}

MIT License

Copyright (c) 2016 IGonics, (*8)

Maintained by

IGonics, (*9)

The Versions

01/03 2017

dev-master

9999999-dev

Specific File Migrations for Laravel 5

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar ggordon