If you're sending to Heroku 1.sql
file generated for H2
, there is big chance that they will conflict, instead, set the Heroku's url in application.conf
as db.default.url
and run it in dev mode on localhost first to generate valid Postres SQL. Also you will need to comment out the db.default.user
and db.default.password
settings, as Heroku's URL contains this information already.
If you don't know current connection's URL you will find it on:
https://postgres.heroku.com/ -> YourDBs
-> db-name -> Connection settings
-> JDBC URL
To connect from localhost (or other machine, not in the Heroku's space) you need to add this param to the URL:
&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
Thanks to this approach you can test your application locally with established connection to the remote Heroku's DB, (don't be surprised - that combination will be much slower than working with local app + local DB
or Heroku app + Heroku DB
) anyway for testing it's better than repeatedly pushing small fixes to the cloud.
Also you'll be able to perform evolutions from localhost - without pushing the code to Heroku, and it's really shorter approach if you have problems in your SQL.
Additionally it's good occasion to turn on SQL logging in local dev mode and hunt for redundant SQL queries, if you'll remove all not necessary queries and will be satisfied on localhost, after deploying to the Heroku, you will be just much more satisfied :)
Reset
If you'll create proper 1.sql
file than most probably you'll need to reset your DB containing invalid structure (as I assume that's not a problem yet as you just moving from local to Heroku). First find a name of the DB for the current app (with bash, in app's folder):
heroku pg
And then reset it with (it will destroy all data so consider backup first if you don't want to loose your data!):
heroku pg:reset HEROKU_DATABASE_SOMEBASE
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…