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:
; 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"]}
but when I run (go) or (reset) I get
Execution error (IllegalArgumentException) at duct.core.resource.Resource/make_reader (resource.clj:13).
Cannot open <nil> as an InputStream.
That usually indicates that the resource cannot be found. Do you have a file at: resources/migrations/wibble.up.sql
?
I'm guessing it can't find my external migration file but they are definately in resources/migrations. Am I missing something here?
Hi @weavejester - I did. Just to check should that be resources/<project name>/migrations ?
or resources/migrations.
In your earlier example, you just used resources/migrations
.
I did but I've noticed resources has a sub directory with my project (so resource/guestbook) if that makes sense.
Yes; ideally you’d use guestbook/migrations
rather than just migrations
, but that’s just convention.
I'll give this a go and let you know how I get on (thanks for the awesome work you've done BTW).
You could also try going to your REPL and seeing if (io/resource "migrations/wibble.up.sql")
returns anything.
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
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"}
I should probably update the template with the new version.
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
Which is fixed in the latest commit of the template
thanks for all the tips everyone. I'll give these a try and get back to you on how I get on. cheers.
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.
If you’re not doing anything proprietary, perhaps post up your repo?
Sure no problem - I'm just playing around so no problem. I'll post up a smaller app which also displays the problem.
Its up there now: https://github.com/shortly-portly/foo
cheers
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?
Shouldn't the [:duct.migrator.ragtime/sql :foo.migration/wibble]
be inside the base profile?
Ah, yes, you’re right @kevin.van.rooijen
Ah - thank you - this has caught me out before on something else. Huge thanks to all. Appreciate the help.
I think there’s a PR for duct/core to make these errors more obvious. I should probably look into merging that!
@weavejester That PR is still open about checking the module keys 🙂
Ah haha
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.
Yeah that's understandable. Looking forward to Ring 2.0 👍
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?
Ah ok. Thanks anyway.
The SkillsMatter site is back up and the videos are available again (with a free login as before)
@jr0cket - just noticed your message - many thanks for the update.