kitloong / laravel-migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
2.51k stars 278 forks source link

table-filename persists between calls and causes file to be overwritten #223

Closed calebdw closed 3 months ago

calebdw commented 3 months ago

Describe the bug Hello!

I have a couple of different connections that I'm trying to dump one after the other:

            $connections = collect(config('database.connections'))
                ->mapWithKeys(fn ($item, $key) => [$key => $item['database']])
                ->each(function ($database, $connection): void {
                    $task     = "Creating migration for database [{$database}] on connection [{$connection}]";
                    $filename = "create_{$connection}_tables.php";

                    $this->components->info($task);

                    $this->call('migrate:generate', [
                        '--connection'     => $connection,
                        '--path'           => $this->path,
                        '--table-filename' => $filename,
                        '--skip-log'       => true,
                        '--skip-proc'      => true,
                        '--skip-views'     => true,
                        '--squash'         => true,
                    ]);
                });

However, each call to migrate:generate is overwriting the file for the first connection instead of creating a new file with the new connection name. If I generate them all individually then every thing works fine, but it seems like there's something that's not getting flushed after every call.

Expected behavior I expect there to be a file for every connection.

Details (please complete the following information):

Thanks!

kitloong commented 3 months ago

Thank you @calebdw

I have fixed the issue, kindly check if it works on your side, thanks!

calebdw commented 3 months ago

That worked, thanks!!