ismail1432/safe-migrations-bundle

Using LoggerInterface instead of SymfonyStyle for customised output

Closed this issue ยท 4 comments

Thanks for this project, it can be very valuable to avoid migration problems during deployments!

To keep a history of my risky migrations (and to know if my next release contains this kind of migration), I want to log all these migrations in a git tracked file.

To do this, I think this project can use LoggerInterface instead of SymfonyStyle output. The project would lose that nice cli output, but gain a lot of flexibility.

If you agree, I can propose a PR to use the Logger.

hi @PaulienM ,

thanks for your suggestion.

IMHO Logger is different that the console output, it's different purpose.

What do you think instead to dispatch events based on risky migrations detected? For your use case you can listen to these events and do what do you want with it.

@ismail1432 maybe you have another ideas :)

Hey @PaulienM

Thank you for the suggestion ๐Ÿ‘
The purpose of the lib is to warn with a message in the console and in the migration (so you can catch it during the review), so I agree with @qdequippe I think we can add an event with the name of the risky migration and the content when a risky change is detected

// DoctrineMigrationDiffListener.php#L67
// something like this
$this->dispatch(new RiskyMigrationEvent(new RiskyMigration($migration, $migrationFileContent);

Hi,
Thank you very much for your feedback ๐Ÿ˜ƒ

I suggested a solution with the Logger (which can be used as a command output) because it seemed to be the simplest to implement. But the solution proposed by @ismail1432 seems to me to be very adapted and customisable.

Hi, Thank you very much for your feedback ๐Ÿ˜ƒ

I suggested a solution with the Logger (which can be used as a command output) because it seemed to be the simplest to implement. But the solution proposed by @ismail1432 seems to me to be very adapted and customisable.

Yes and you can already use it, just update the lib and do it! You can see an example here