lecaillon / Evolve

Database migration tool for .NET and .NET Core projects. Inspired by Flyway.
https://evolve-db.netlify.com
MIT License
849 stars 111 forks source link

[question] how to capture all SQL so that it can be applied by some other tool? #294

Open danhaywood opened 1 year ago

danhaywood commented 1 year ago

Our DBAs like to use their own tooling for any scripts to be applied into production, and they have a process whereby the rehearse running in the scripts against a staging environment, then run it in "for real" against prod.

I'm trying to integrate Evolve with this process. My thinking is to run Evolve with --transaction-mode RollbackOnly, but ... somehow ... capture a log of all the SQL that Evolve would have run in. Then, take this SQL and package it into a format for our DBAs to run.

Looking at the code, I see that the SQL is available in WrappedConnectionEx#Execute(...), but I can't see any obvious way of being able to append that SQL into a log.

Is there any way to accomplish this requirement? If not, would you accept a PR to add in this capability?

danhaywood commented 1 year ago

I've found a bit of a workaround, which is to implement a decorator of DbConnection (following this blog post) and then write my own CLI which uses Evolve as a nuget package. But it would still be nice if this capability was available in the Evolve CLI itself.