awssat / laravel-sync-migration

Developer tool helps to sync migrations without refreshing the database
MIT License
108 stars 13 forks source link

allow to specify migration file path #10

Closed vesper8 closed 4 months ago

vesper8 commented 2 years ago

It would be nice if you could specify a single migration file to perform a sync over, rather than allowing the sync command to iterate over dozens of migrations every time

BSN4 commented 2 years ago

PRs are welcome

vesper8 commented 2 years ago

Not a PR but this is how I solved it

    protected $signature = 'migrate:sync {--migration=}';

    ...

    public function handle()
    {
        $files = $this->migrator->getMigrationFiles($this->getMigrationPaths());

        foreach ($files as $file) {
            if ($this->option('migration')) {
                if (stripos($file, $this->option('migration')) > -1) {
                    $this->processMigration(file_get_contents($file));
                }
            } else {
                $this->processMigration(file_get_contents($file));
            }
        }

        ...

    }