Fork me on GitHub
#sql
<
2019-09-10
>
gerred01:09:50

what's everyone like for managing their schema and/or performing migrations?

seancorfield02:09:55

We rolled our own at work (because we got started with it before we adopted Clojure -- and then we rolled our own Clojure version of our legacy migration system 🙂 ).

seancorfield02:09:04

But I think Migratus is fairly popular.

seancorfield02:09:37

There's also Ragtime

seancorfield02:09:12

I think if we were starting from scratch, we might go with Migratus because it addresses the linear ordering problem that Ragtime has.

gerred04:09:04

migratus looks nice.

jmayaalv06:09:44

we have been using migratus for +2 years and like it very much.

pyr07:09:59

we've been reasonably happy with ragtime as it allows to migrate not only sql

pyr07:09:18

(which is a plus in our case)

dharrigan07:09:54

been using flyway since a long time, works really well

dharrigan08:09:11

Hi @seancorfield you know your examples of using plan, i.e.,

dharrigan08:09:20

user=> (into #{}
             (map :name)
             (jdbc/plan ds ["select * from address"]))

dharrigan08:09:41

how would I select more than one column, i.e., :name and :foo?

mpenet09:09:48

(map #(select-keys % [....])) if you want a map with these keys

mpenet09:09:59

or (map (juxt :name :foo)) if you want a tuple

dharrigan09:09:21

ahhh, I had the select-keys, but in d'oh moment forgot the '#' to indicate inline anonymous function!

dharrigan09:09:33

man, where is my head today!

dharrigan09:09:42

Thanks Max! 🙂

gerred11:09:08

ok curious how people are using migratus without leiningen - are you making clj aliases with a separate main? should I just get over only wanting to use tools.deps? 😉 are you just REPL-ing into prod? 😉

jmayaalv11:09:50

we let the app run the migrations every time the app starts. This way code/db are always synced. We have bash scripts to help us create new migration files. We use tools.deps

dharrigan11:09:02

I do that too. I have my migration kick in when the app starts

dharrigan11:09:37

I use integrant to "inject" the migration function which kickstarts the migration of the db.

seancorfield16:09:23

We run our "migration task" as a deliberate deployment action. We can include it as part of a full build deployment or we can run it on its own. We use CLI/`deps.edn` for everything -- we switched from lein to boot in 2015 and to the new tools last year. And, yes, we have REPLs in (some) production processes and we do occasionally apply code patches live that way (mostly the REPL, for us, is used for diagnostics/investigation).

seancorfield16:09:58

We have over half a dozen separate apps on half a dozen servers that run against our primary DB so running migrations as part of app startup would not make sense for us.

kulminaator17:09:49

we have separated databases for all the services that we use. less headache 🙂. but we only did it because it made sense for us and our use cases actually allow it.

kulminaator17:09:47

as for migrations on every (test/dev) run - dont forget to rebase every now and then ... replaying 4 or 14 years of migrations step by step is going to cost you a lot of time 🙂

gerred17:09:35

yeah I've always been paranoid ops and triggered migrations manually.

kulminaator19:09:53

if you do well enough you will do them somewhat manually again 😄

kulminaator19:09:27

db migrations get tender when your databases grow into terabytes

kulminaator19:09:32

and most tooling is illsuited

geraldodev21:09:59

any successfull use of next.jdbc with oracle ? I'm not getting the namespaced keywords

seancorfield21:09:38

@geraldodev I don't have an Oracle install to test against. If you're not getting namespaced keywords back from Oracle in next.jdbc with a default set of options (i.e., no :builder-fn) then it would seem that calling .getTableName returns an empty string (or null) on Oracle -- and there's not much I can do about that.

geraldodev23:09:06

@seancorfield thank you for the info

seancorfield23:09:11

Oracle continues to be a thorn in everyone's side I think 🙂 I can only do what the JDBC driver allows.

geraldodev23:09:41

I've even downloaded an updated one to see if it would fix the problem

geraldodev23:09:34

I've also used next.jdbc with hugsql and its adapter https://gitlab.com/nikperic/hugsql-next-jdbc/blob/master/src/hugsql/adapter/next_jdbc.clj#L17 This call has a little conflict with next.jdbc instrumentated. the instrumentation expects a map and it's sometimes passing a nil. Thank you for the effort of rewriting jdbc. Very appreciated work. I want to learn datafy and nav and I am eager to try with next.jdbc.