Fork me on GitHub
#duct
<
2020-03-21
>
Dave Simmons19:03:18

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 Simmons19:03:40

; 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 Simmons19:03:58

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

Dave Simmons19:03:26

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

Dave Simmons19:03:41

Cannot open <nil> as an InputStream.

weavejester19:03:24

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

Dave Simmons19:03:28

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

Dave Simmons19:03:24

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

Dave Simmons19:03:30

or resources/migrations.

weavejester19:03:01

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

Dave Simmons20:03:05

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

weavejester20:03:43

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

Dave Simmons20:03:15

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

weavejester20:03:52

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

kwrooijen20:03:22

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

kwrooijen20:03:32

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"}

lol 1
weavejester20:03:54

I should probably update the template with the new version.

kwrooijen20:03:01

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

kwrooijen20:03:20

Which is fixed in the latest commit of the template

Dave Simmons20:03:00

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

Dave Simmons20:03:15

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.

weavejester20:03:25

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

Dave Simmons20:03:11

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

weavejester20:03:33

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?

kwrooijen20:03:46

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

Dave Simmons20:03:18

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

weavejester20:03:44

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

kwrooijen20:03:48

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

weavejester20:03:14

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.

kwrooijen20:03:49

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

Dave Simmons20:03:10

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?

weavejester02:03:48

No, but Skills Matter should have their site back up at some point, as they got investor backing… although maybe they won’t be able to weather COVID-19.

Dave Simmons07:03:11

Ah ok. Thanks anyway.

practicalli-john08:03:04

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

Dave Simmons09:03:43

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