-
Notifications
You must be signed in to change notification settings - Fork 145
Issue with Heroku deployment #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't believe this is Luminus specific and if it works locally, then It could be an issue with the URL for Heroku according to this. Check to make sure that the |
The database URL (DATABASE_URL) is set automatically by Heroku when the PostgreSQL addon is created. Also, I am able to connect to PostgreSQL directly like this: (require '[clojure.java.jdbc :as db]) If it matters, my project.clj dependencies are currently these:
(from https://devcenter.heroku.com/articles/clojure-web-application) So is the issue maybe with yesql or some other library since direct JDBC access works? |
Another issue I have with Heroku deployments is that "heroku run lein repl" takes forever to start up and seems to time out about every second time. |
It sounds like the issue might be somewhere else, I doubt it's yesql since it just piggybacks on clojure.java.jdbc. Using
|
It might be an issue with environ that's used within Luminus. The library will try to resolve environment variables and should generate |
I found the issue. It turns out db-spec needs to be a string for the username:password type URL that Heroku uses to work. It would be great if you could update your Heroku deployment documentation to reflect this. For details, check out the get-connection function in clojure.java.jdbc: This works: (DriverManager/getConnection "jdbc:postgresql://ec2-54-217-202-108.eu-west-1.compute.amazonaws.com:5432/dcql6a1c91v5up" (as-properties {:user "uorytkslaggjoj", :password ""}) But this doesn't: (DriverManager/getConnection (System/getenv "DATABASE_URL")) |
NOTE: the db-spec needs to be changed to a string in db/migrations.clj as well as it's duplicated there. |
And now for the next stumbling block on Heroku... Migrations run fine locally on postgresql (lein run migrate) but not on Heroku (heroku run lein run migrate). I get this exception: INFO: Starting migrations |
Ah, I'll definitely update the docs for Heroku connection url. You should be able to run migrations from the compiled jar by running |
Out of curiosity, how are you populating the {:provided {:env {:database-url "jdbc:postgresql://localhost/app_dev?user=gallery&password=pictures"}}} The string in the
The {:store :database
:db {:connection-uri (:database-url env)}} The clojure.java.jdbc accepts the :connection-uri key with the raw connection string. |
I am passing in the Heroku postgresql URL string directly as the db-spec (or db) instead of a map. That should work with jdbc/get-connection. However, when I run the migrations, I get this: peter@Peters-MacBook-Air ~/src/marklunds]$ heroku run java -jar target/marklunds.jar migrate As you can see it successfully creates the schema_migrations table but then it falls over. |
The documentation for
|
You can also pass a string to jdbc/get-connection though according to the same documentation: " String: In fact, as I wrote above, that's what you need to do on Heroku for the Heroku DATABASE_URL to be parsed. Here is my corresponding REPL session where migrations fail: marklunds.core=> (require '[clojure.java.jdbc :as sql]) |
I tested with both approaches locally and you're right either a string or a map will work. I'm not sure why the map isn't working for you on heroku as it's the same URL string in both cases though. |
Yes, I believe I have run into this problem. I had some workarounds which I intended to integrate back into mainstream but I never got around to it. This is in my to-do list as I plan on using Heroku. |
For example, my patch for Korma accepts both, jdbc as well as Heroku-like URIs: korma/Korma#316 |
looks like we might need a function in db.core to handle different kinds of urls then |
@yogthos actually, many libraries should handle those URLs, so I created this little library: https://github.com/carouselapps/to-jdbc-uri |
Good idea, if using the library to parse different style URIs would be the best approach. If it works with both Heroku style and jdbc URIs then I think it would make sense to update Luminus to use it. |
Yes, that's the goal of the library. I wonder whether it should be used by Luminus or by the other libraries, like migratus, yesql, korma, etc. Having it in more than one place is not a problem as it's a no-op for proper jdbc URIs. It works for Heroku and JDBC at the moment. I'm open to add more. |
I think it would probably be easier to start using it in Luminus first, as it doesn't require buy in from the library maintainers. |
Agreed. J. Pablo Fernández pupeno@pupeno.com
|
There you go: #140 |
@pupeno oh by the way does this lib do the same thing by any chance? :) https://github.com/weavejester/hanami |
Yeah, it kinda does. I intend to-jdbc-uri to be more generic than just Heroku though. |
I think that's a good plan. :) |
@peter the problem should be solved in the latest template thanks to the library from @pupeno that parses both the Heroku and JDBC style URLs. The following steps should resolve the issue: add the dependency: [to-jdbc-uri "0.1.0"] require: [to-jdbc-uri.core :refer [to-jdbc-uri]] then set the :connection-uri (to-jdbc-uri (:database-url env)) |
I'm going to close this one as it should be working now. |
This may not be a problem with the Luminus framework as such but there seems to be issues with Heroku deployment. I keep getting "SQLException No suitable driver found" (DriverManager.java:689). I created my luminus app with +postgres and I have tried a variety of different postgresql driver versions to no avail. Any idea what the issue could be? The apps work great for me locally on my Macbook.
The text was updated successfully, but these errors were encountered: