[Feature Request] Write SQL Executed to Migration Table #2147
Replies: 2 comments 2 replies
-
Thank you for submitting a feature request. A few notes:
I'm not sure if you've used a logger when migrating before, but if not, I would recommend doing so. I'd appreciate feedback about this from other Sequel users. Currently, the use case seems sufficiently niche to me that I wouldn't ship an extension for it with Sequel, but I'm open to being convinced otherwise. |
Beta Was this translation helpful? Give feedback.
-
@jvanderen1 we have a similar setup with staging environments and we use some custom rake tasks to track deployed migrations and handle automatic rollbacks. Just wanted to share some code in case it might help in your case.
|
Beta Was this translation helpful? Give feedback.
-
Feature Request
For our team, it has become a slight pain to figure out what SQL was executed during a migration. There are a few cases where we need to know this:
A migration may have partially succeeded, but ultimately failed. This could lead to problems trying to debug what exactly has changed. While we can look at the last error thrown, it does not make it immediately clear which SQL statements need to be reversed or triaged.
The code which executed on a shared PostgreSQL instance may not be available anymore. Maybe a dev forgot to trigger
down
before removing the code? While it would be ideal to have automaticdown
migration occur scripts before they are modified / deleted, this is painful to backtrace sometimes. Also, there is the risk thatdown
may not work properly. (Maybe we should also report all SQL migration queries executed, even for 1 migration?)Sometimes, depending on the environment, SQL queries may execute differently. This could be due to how the schema has evolved over time or which additional frameworks are interacting with PostgreSQL or Models, but it would be helpful to debug any inconsistencies in executed SQL.
Certain SQL migrations may have executed through a variable. This is a pattern to probably avoid, but it is still possible to execute migrations through variables. Having a way to trace exactly what executed would be helpful.
Thanks for making an amazing framework!
Beta Was this translation helpful? Give feedback.
All reactions