migrations icon indicating copy to clipboard operation
migrations copied to clipboard

[Feature] Display the migration output from the base Doctrine migrator.

Open garret-gunter opened this issue 7 years ago • 2 comments

Detailed Description

Currently only the migration notes are displayed. But any other output from the base doctrine migrator won't be written to console.

Context

It would be nice to see the extra output from doctrine. I made a quick, dirty solution to show the difference.

Current behavior: image

With doctrine output: image

Possible Implementation

Doctrine's \Doctrine\DBAL\Migrations\Configuration\Configuration class has an outputWriter property. The property must be an instance of \Doctrine\DBAL\Migrations\OutputWriter. Here is my dirty workaround.

I set the output writer after retrieving the configuration from the provider.
https://github.com/laravel-doctrine/migrations/blob/f1292c3dcb894bf5d310775e4bb1d9bd9e74d658/src/Console/MigrateCommand.php#L49-L53


        $configuration->setOutputWriter(new OutputWriter(function($message){
                // Get  the current command's output handler.
        	$output = $this->getOutput();
               // Verify the handler exists and that we want extra output.
        	if($output && $output->isVerbose()){
                        // Write the output to a new line.
        		$output->write($message,true);
	        }
        }));

I don't know how to get an Artisan command's output handler from the ConfigurationFactory. The only way I know how is to get it from the command itself.

Edit

The command could also pass it's output handler to the ConfigurationProvider::getForConnection() method.

garret-gunter avatar Feb 14 '18 23:02 garret-gunter

Sorry for the late reply. Happy to accept a PR for it.

patrickbrouwers avatar Apr 06 '18 20:04 patrickbrouwers

This might be something for us to handle when updating to doctrine/migrations 2.x.

garret-gunter avatar Jun 14 '19 21:06 garret-gunter