Fork me on GitHub

I am using library for managing postgres migrations, and with my CI/CD setup, at starting point I am running all the migrations before tests, which runs all the up migrations. We are using git for source control. Currently, there are multiple people using our dev testing environment and if I have deployed my branch, if someone else wants to deploy their branch(or main branch), I have to run the down migrations(which are not there in someone else’s branch) manually by SSHing/REPLing to our database host. Is there a way to rollback the migrations which are different between two git branches? We can’t rollback all the migrations, because it’s a common testing environment which many people use and we don’t want to erase all the data.


Don't use a shared dev testing environment. Everyone should have their own isolated local environment.


Yes, shared dev testing environment has been a pain point, but that’s the way it has been with my org and team. Also. it’s not just shared environment that can cause this. Say that, I have deployed version B, which runs a new migration script in production, now, due to some issues if I have to roll back to version A, I first have to manually SSH/REPL into the production DB host and run the down migrations.


I’d expect few down migrations(diff between the versions) to be run when we downgrade the version


It's pretty normal to run down migrations manually.


Ah okay, maybe I am finding it cumbersome because of the shared environment, gotta figure out some way to fix that. Thanks for the response, Sean


If I were you, one option to explore is just to run local docker containers with your db of choice

👍 1
☝️ 1

It's trivially easy to spin up a docker container with postgres/mysql/whatever (and if you're on windows, I believe you can also spin up sql server)


that way, it's all isolated just to you.


Yeah that's what we do : MySQL, Redis, Elastic Search via Docker, Clojure via the CLI. Makes it easy to do everything locally.

👍 1

You're trying to find a workaround for a bad idea.


using next.jdbc, is there anyway to get joins as nested maps? (e.g. in a one-to-one relationship), or this is something usually done as a normal transformation on built rows?


(similar to how datalog joins would return the data with pull)


No but there's a Github issue about providing functions to do that transform

👌 1

For some databases, you can convert the join to be a subquery, then do a JSON query instead.

👍 1

thanks, I’ll upvote that issue and do my own helpers for now