Errors in evolution on Heroku

I tried to push some evolutions towards Heroku:

2012-08-30T10:58:00+00:00 heroku[slugc]: Slug compilation finished 2012-08-30T10:58:02+00:00 heroku[web.1]: Starting process with command `target/start -Dhttp.port=32436 -Xmx384m -Xss512k -XX:+UseCompressedOops` 2012-08-30T10:58:03+00:00 app[web.1]: Play server process ID is 2 2012-08-30T10:58:05+00:00 app[web.1]: [←[37minfo←[0m] play - database [default] connected at [Database-address] 2012-08-30T10:58:05+00:00 app[web.1]: CREATE TABLE `unapprovedteaminfo` ( --- Copy of 1.sql --- 2012-08-30T10:58:05+00:00 app[web.1]: VALUES (1, 2, 2, '2012-01-01 00:00:00', 'k'); 2012-08-30T10:58:05+00:00 app[web.1]: ERROR: syntax error at or near "`" 2012-08-30T10:58:05+00:00 app[web.1]: Position: 14 [ERROR:0, SQLSTATE:42601] 2012-08-30T10:58:05+00:00 app[web.1]: Oops, cannot start the server. 2012-08-30T10:58:05+00:00 app[web.1]: PlayException: Database 'default' is in inconsistent state! [An evolution has not been applied properly. Please check the problem and resolve it manually before marking it as resolved.] 2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.Evolutions$.checkEvolutionsState(Evolutions.scala:155) 2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.Evolutions$.databaseEvolutions(Evolutions.scala:308) 2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.Evolutions$.evolutionScript(Evolutions.scala:284) 2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.s cala:412) 2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.s cala:410) 2012-08-30T10:58:05+00:00 app[web.1]: at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59 ) 2012-08-30T10:58:05+00:00 app[web.1]: at scala.collection.immutable.List.foreach(List.scala:45) 2012-08-30T10:58:05+00:00 app[web.1]: at play.api.db.evolutions.EvolutionsPlugin.onStart(Evolutions.scala:410) 2012-08-30T10:58:05+00:00 app[web.1]: at play.api.Play$$anonfun$start$1.apply(Play.scala:60) 2012-08-30T10:58:05+00:00 app[web.1]: at play.api.Play$$anonfun$start$1.apply(Play.scala:60) 2012-08-30T10:58:05+00:00 app[web.1]: at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59 ) 2012-08-30T10:58:05+00:00 app[web.1]: at scala.collection.immutable.List.foreach(List.scala:45) 2012-08-30T10:58:05+00:00 app[web.1]: at play.api.Play$.start(Play.scala:60) 2012-08-30T10:58:05+00:00 app[web.1]: at play.core.StaticApplication.<init>(ApplicationProvider.scala:51) 2012-08-30T10:58:05+00:00 app[web.1]: at play.core.server.NettyServer$.createServer(NettyServer.scala:132) 2012-08-30T10:58:05+00:00 app[web.1]: at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:153) 2012-08-30T10:58:05+00:00 app[web.1]: at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:152) 2012-08-30T10:58:05+00:00 app[web.1]: at scala.Option.map(Option.scala:133) 2012-08-30T10:58:05+00:00 app[web.1]: at play.core.server.NettyServer$.main(NettyServer.scala:152) 2012-08-30T10:58:05+00:00 app[web.1]: at play.core.server.NettyServer.main(NettyServer.scala) 2012-08-30T10:58:06+00:00 heroku[web.1]: Process exited with status 255 2012-08-30T10:58:06+00:00 heroku[web.1]: State changed from starting to crashed 

These evolutions will work fine with H2, I think there should be some problems with the POSTGRESQL syntax. Anyway, the problem that I am facing now is that even if I change 1.sql and press the new version on Heroku, the same error will appear in the logs - the copied 1.sql will not change according to the new pressed version .

+6
source share
2 answers

If you send to the Heroku 1.sql file generated for H2 , there is a high probability that they conflict, instead set the Heroku URL in application.conf as db.default.url and run it in dev mode on localhost first to generate valid Postres SQL. You will also need to comment on the settings of db.default.user and db.default.password , as the Heroku URL already contains this information.

If you do not know the current connection URL, you will find it:

https://postgres.heroku.com/ β†’ YourDBs β†’ db-name β†’ Connection settings β†’ JDBC URL

To connect with localhost (or another computer, not in Heroku space), you need to add this parameter to the URL:

 &ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory 

Thanks to this approach, you can test your application locally with a connection to a remote Heroku database (do not be surprised - this combination will be much slower than working with local app + local DB or Heroku app + Heroku DB ), in any case, testing is better than repeatedly push small corrections to the cloud.

You can also perform evolution from localhost - without clicking on the code in Heroku, and this is a very short approach if you have problems in your SQL.

In addition, it’s nice to turn off SQL logging in local detector mode and look for redundant SQL queries if you delete all unnecessary queries and are satisfied on localhost, after deployment in Heroku you will just be more satisfied :)

Reset

If you create the correct 1.sql file, than most likely you will need to reset your database containing an invalid structure (since I assume that this is not a problem yet, since you are simply moving from local to Heroku). First, find the database name for the current application (with bash, in the application folder):

 heroku pg 

And then reset it with (it will destroy all data, so first think about backing up if you don't want to lose your data!):

 heroku pg:reset HEROKU_DATABASE_SOMEBASE 
+22
source

I think you have some problems with defining in VALUES with a data field. I published my development configuration setting for games 2.4, Slick 3.0.3 and postgres. I automatically created * .sql files placed in the evolution folder.

Restore evolution scenarios in game 2

Greetings

0
source

Source: https://habr.com/ru/post/924163/


All Articles