coast icon indicating copy to clipboard operation
coast copied to clipboard

Multi-command .sql migrations

Open armstnp opened this issue 2 years ago • 0 comments

Currently, .sql migration files do not support multiple commands. The entire string is passed in to clojure.java.jdbc/db-do-commands. According to the changelog, as of 2016:

db-do-commands now expects multiple commands to be be wrapped in a vector JDBC-122. The single command form is unchanged (but may be wrapped in a vector).

This behaviour is reflected when multi-command migrations are run: only the first command takes effect, and the rest are silently skipped.

One way to mitigate this could be to require sentry lines between subcommands of a given migration direction, in a similar way to how up and down direction pragmas are implemented.


On a similar vein, unfortunately, there also seems to be issues that I can't quite pin down in the application of split Clojure migrations. When running a migration with up and down functions, coast db migrate seems to be trying to pick and run the down migration instead of the up. What's odd is that the code and docs don't seem to have this wrong, so I'm not sure why this is. After digging a bit further, I think I have an idea of the culprit, dealt with in #111.

armstnp avatar Jan 25 '23 08:01 armstnp