doctrine / migrations

Doctrine Database Migrations Library
https://www.doctrine-project.org/projects/migrations.html
MIT License
4.65k stars 386 forks source link

Ability to hook in to the Migration-generation for additional changes to the schema #1362

Closed LeonidasJP closed 9 months ago

LeonidasJP commented 9 months ago

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

Is there a possibility to hook in to migrations:diff, to add additional changes to the diff generated by migrations:diff?

I'm working on a custom anonimization tool, which maps the "method to anonymize" to a database comment. Updating the comment directly works for new tables and for columns, but not for already existing tables. This might also be more prone to typos or unsupported syntax, so I'm planning to use custom annotations/attributes (@Anonymize / @AnonymizeExcept), but I have yet to find a way to have those annotations be seen and alter the database comments for me.

Is there a way I can hook in to the migrations:diff process, so I can:

stof commented 9 months ago

To me, this should be done by hooking into the postGenerateSchema event of the ORM to modify the Schema object to define the expected comment.

The DBAL schema-diffing should be able to update the comment (and if not, it would be a legitimate feature request on the DBAL project.

LeonidasJP commented 9 months ago

Thanks for the input, @stof! Seems I was looking in the wrong place to start to hook in.

LeonidasJP commented 9 months ago

I noticed DBAL does generate the schema correctly, but is not noticing the changed comment in the TableDiff. I have opened an issue DBAL-side (doctrine/dbal#6205) to request/fix that. Will close this issue in favor of the DBAL sided one