Fork me on GitHub
#duct
<
2018-03-13
>
mariusz_jachimowicz09:03:27

@myguidingstar we could say that we have Clojure on Duct as similar to Ruby on Rails hehehehehehe. Duct is awesome. 😄

myguidingstar10:03:16

totally agree 😄

jumar13:03:53

I'm trying to setup ragtime migrations in my project - looking at https://github.com/duct-framework/migrator.ragtime. I really don't want to write my sql scripts inside the config.edn file. There's a mention that URLs are possible:

Migrations built in this way expect an :up and a :down key that contain vectors of SQL, either as strings, or URLs to resources on the classpath.

jumar13:03:32

However, I'm having a hard time to figure out how to do that. I've tried this:

:duct.migrator/ragtime
 {:migrations [#ig/ref :my-app.migrations/init]}

 [:duct.migrator.ragtime/sql :my-app.migrations/init]
 {:up ["migrations/2018-13-03-init.sql"]
  :down []}

but got sql exception:
Caused by org.postgresql.util.PSQLException
   ERROR: syntax error at or near "migrations" Position: 1

jumar13:03:18

How people usually do that? I can't imagine that putting all those scripts into a config is a manageable way to do that... Ideally, I'd like to just configure the directory that contains all db migration scripts and everything else will be handled automatically without any need to always add a new config when new migration script is added.

mariusz_jachimowicz14:03:05

@jumar try :up [#duct/resource "migrations/2018-13-03-init.sql"]

jumar14:03:29

@mariusz_jachimowicz great, that indeed seems to work - thanks! Any ideas about automating migrations handling (i.e. without having to update config.edn every time I add new migration script)

mariusz_jachimowicz14:03:39

you can try my module https://github.com/mariusz-jachimowicz-83/duct-migrations-auto-cfg if you don't want to write migrations references each time.

jumar14:03:53

Will look into that - thanks.

jumar14:03:13

@weavejester do you use the manual approach by writing the migrations inside the config file?

mariusz_jachimowicz14:03:24

@jumar you can also look on https://github.com/mariusz-jachimowicz-83/ragtime-clj if you want more advanced migrations - as an clj files. Just include the namespace.