duct

Dave Simmons 2020-03-21T19:55:18.123400Z

Hi all. I'm pretty new to Duct but really enjoying it. I've come across an issue and I'm not sure if it is user error or not. I have the following ragtime migration defined in my config.edn:

Dave Simmons 2020-03-21T19:55:40.123600Z

; Migrations :duct.migrator/ragtime {:migrations [#ig/ref :guestbook.migration/create-guestbook]} [:duct.migrator.ragtime/sql :guestbook.migration/create-guestbook] {:up [#duct/resource "migrations/wibble.up.sql"] :down [#duct/resource "migrations/wibble.down.sql"]}

Dave Simmons 2020-03-21T19:55:58.124Z

but when I run (go) or (reset) I get

Dave Simmons 2020-03-21T19:56:26.124200Z

Execution error (IllegalArgumentException) at duct.core.resource.Resource/make_reader (resource.clj:13).

Dave Simmons 2020-03-21T19:56:41.124400Z

Cannot open <nil> as an InputStream.

2020-03-21T19:57:24.125700Z

That usually indicates that the resource cannot be found. Do you have a file at: resources/migrations/wibble.up.sql?

Dave Simmons 2020-03-21T19:57:28.125900Z

I'm guessing it can't find my external migration file but they are definately in resources/migrations. Am I missing something here?

Dave Simmons 2020-03-21T19:58:24.126900Z

Hi @weavejester - I did. Just to check should that be resources/<project name>/migrations ?

Dave Simmons 2020-03-21T19:58:30.127100Z

or resources/migrations.

2020-03-21T19:59:01.127700Z

In your earlier example, you just used resources/migrations.

Dave Simmons 2020-03-21T20:00:05.128800Z

I did but I've noticed resources has a sub directory with my project (so resource/guestbook) if that makes sense.

2020-03-21T20:00:43.129600Z

Yes; ideally you’d use guestbook/migrations rather than just migrations, but that’s just convention.

Dave Simmons 2020-03-21T20:01:15.130600Z

I'll give this a go and let you know how I get on (thanks for the awesome work you've done BTW).

2020-03-21T20:01:52.131700Z

You could also try going to your REPL and seeing if (io/resource "migrations/wibble.up.sql") returns anything.

kwrooijen 2020-03-21T20:03:22.132400Z

Although I doubt this is the issue; If you're using the lein template, then the sql module is probably outdated. [duct/module.sql "0.6.0"] Is the latest. iirc there's also an update for ragtime in there. Just an FYI

kwrooijen 2020-03-21T20:06:32.133500Z

The new ragtime version also allows you to automatically include migrations, instead of having to write all of them in your config:

:duct.migrator/ragtime
 {:migrations #ig/ref :duct.migrator.ragtime/resources
  :database #ig/ref :duct.database/sql}

 :duct.migrator.ragtime/resources {:path "myapp/migrations"}

2020-03-21T20:08:54.133900Z

I should probably update the template with the new version.

kwrooijen 2020-03-21T20:12:01.135100Z

I think that would be nice. The current template is also still on 0.7.0. And if you update to 0.8.0 it breaks because the hawk dependency is missing

kwrooijen 2020-03-21T20:12:20.135400Z

Which is fixed in the latest commit of the template

Dave Simmons 2020-03-21T20:16:00.136200Z

thanks for all the tips everyone. I'll give these a try and get back to you on how I get on. cheers.

Dave Simmons 2020-03-21T20:38:15.137400Z

Getting a bit further 🙂. I changed the resource path to "guestbook/migrations/wibble.up.sql" and now I get a db-spec null is missing a required parameter.

2020-03-21T20:39:25.137900Z

If you’re not doing anything proprietary, perhaps post up your repo?

Dave Simmons 2020-03-21T20:40:11.138800Z

Sure no problem - I'm just playing around so no problem. I'll post up a smaller app which also displays the problem.

Dave Simmons 2020-03-21T20:43:36.139100Z

Its up there now: https://github.com/shortly-portly/foo

Dave Simmons 2020-03-21T20:43:41.139400Z

cheers

2020-03-21T20:46:33.140800Z

I don’t see anything obviously wrong with that… when the exception occurs, can you (pst) it? What happens if you lein clean and restart your REPL?

kwrooijen 2020-03-21T20:48:46.141200Z

Shouldn't the [:duct.migrator.ragtime/sql :foo.migration/wibble] be inside the base profile?

2020-03-21T20:49:33.141600Z

Ah, yes, you’re right @kevin.van.rooijen

Dave Simmons 2020-03-21T20:50:18.142600Z

Ah - thank you - this has caught me out before on something else. Huge thanks to all. Appreciate the help.

2020-03-21T20:50:44.143600Z

I think there’s a PR for duct/core to make these errors more obvious. I should probably look into merging that!

kwrooijen 2020-03-21T20:50:48.143800Z

@weavejester That PR is still open about checking the module keys 🙂

kwrooijen 2020-03-21T20:51:05.144100Z

Ah haha

2020-03-21T20:52:14.145200Z

I’ve been busy with a contract recently and with Clojurist’s Together funding of Ring, so I haven’t had a chance to look into Duct I’m afraid.

kwrooijen 2020-03-21T20:52:49.145800Z

Yeah that's understandable. Looking forward to Ring 2.0 👍

Dave Simmons 2020-03-21T20:54:10.146900Z

Actually @weavejester - while you are online - there is a video of you talking about integrant at Skills Matter but their site seems to be down. Do you know if there are any other links to the presentation?

Dave Simmons 2020-03-22T07:38:11.147600Z

Ah ok. Thanks anyway.

practicalli-john 2020-03-24T08:10:04.147900Z

The SkillsMatter site is back up and the videos are available again (with a free login as before)

Dave Simmons 2020-03-28T09:19:43.007800Z

@jr0cket - just noticed your message - many thanks for the update.