Fork me on GitHub
#sql
<
2022-03-16
>
Pratik12:03:48

I am using https://github.com/weavejester/ragtime 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.

seancorfield13:03:34

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

3
Pratik13:03:22

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.

Pratik13:03:24

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

seancorfield13:03:43

It's pretty normal to run down migrations manually.

Pratik14:03:57

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

dharrigan15:03:22

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

1
👍 1
☝️ 1
dharrigan15:03:46

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)

dharrigan15:03:54

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

seancorfield15:03:01

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

👍 1
seancorfield13:03:01

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

bortexz15:03:32

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?

bortexz15:03:57

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

seancorfield15:03:17

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

👌 1
isak15:03:16

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

👍 1
bortexz15:03:21

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