sql

All things SQL and JDBC...
jwoods 2020-02-03T03:58:15.054300Z

@seancorfield looking into next.jdbc I will let you know if I have questions Thanks for the help.

seancorfield 2020-02-03T04:01:23.055700Z

Sure thing. We use it very heavily at work for MySQL. I maintain HoneySQL as well, these days, so I can answer Qs about that if you go that way (and there's a #honeysql channel). You'll run across clojure.java.jdbc in a lot of the books/tutorials which I maintained for eight years as the forerunner to next.jdbc.

🙂 1
jwoods 2020-02-03T04:31:02.057Z

@seancorfield db migrations are not a thing correct? I'm okay creating and updating a db I just want to try and do the standard thing.

seancorfield 2020-02-03T04:31:50.057600Z

There are several migration libraries... Migratus is one that comes to mind (although I don't use any of them).

seancorfield 2020-02-03T04:32:03.058Z

We have our own custom migration code at work.

seancorfield 2020-02-03T04:32:42.058200Z

https://github.com/weavejester/ragtime

seancorfield 2020-02-03T04:32:53.058500Z

https://github.com/yogthos/migratus

seancorfield 2020-02-03T04:33:19.059100Z

One of those uses date/time stamps which is probably what we'd use at work if we were starting over.

seancorfield 2020-02-03T04:33:38.059600Z

We went with a DB "version" number, which is what the other of those two libs does.

seancorfield 2020-02-03T04:34:22.060100Z

Yeah, Migratus uses the timestamps. That's the one I was thinking of.

jwoods 2020-02-03T04:35:55.060300Z

sweet thanks

Cora (she/her) 2020-02-03T05:16:27.060600Z

migratus is nice

dharrigan 2020-02-03T06:33:05.061300Z

@jdwoodsy1 I use FlywayDB - super easy to use, althought nothing "native" for Clojure, the interop is trival. I use FlywayDB for my Kotlin projects too.

dharrigan 2020-02-03T06:34:57.061600Z

Here is an example <https://git.sr.ht/~dharrigan/startrek/tree/master/src/startrek/migration.clj>

jwoods 2020-02-03T14:02:44.061900Z

Thanks I will look into this as well.

2020-02-03T17:17:07.064800Z

hi guys I'm using Postgres advisory locks for a process that is inconveniently situated to squash into a single transaction. I'm also using Hikari Connection Pool, and I'm wondering if this is a bad combination. What are the chances of

pg_advisory_unlock
happening on a completely different connection to the one that acquired the lock. (5 in 6, I presume)

2020-02-03T17:17:26.064900Z

Is there a body of wisdom about how to approach this?

2020-02-03T17:17:56.065100Z

should I just use

jdbc/with-db-connection
for the entire process

2020-02-03T17:38:46.065700Z

oh sorry, I though pinning was private

isak 2020-02-03T18:11:09.065900Z

@ben.hammond I'm not an expert on this, but I see they use pg_backend_pid() in que (a ruby job system based on advisory locks)

2020-02-03T20:05:58.066600Z

interesting. thanks

2020-02-03T20:29:01.066800Z

I worked on a project that at one point used advisory locks in a job queue kind of thing, I don't recall if that was just an initial design or it went to production with it. You definitely need to be careful mixing them with a connection pool (which it sounds like what your question was). You'll want to get a connection from the pool and keep it and not return it to the pool until you unlock

👍 1