How to use H2 for test and mysql for prod


(Mohit Jaggi) #1

H2 and mysql have different syntax, so my evolutions script works for one but not the other.

e.g. H2 does not seem to like table names without double quotes but mysql fails if there are quotes. I added MODE=MYSQL for H2 but “sbt test” shows failed tests due to non existent tables. I guess evolutions failed but I don’t know how to turn logs on for that and confirm. These tests worked when table names were in double quotes (and db was “default” but that should not matter, I think).


(Mohit Jaggi) #2

I used TRACE_LEVEL_SYSTEM_OUT=4 and I got the following. It seems that evolutions is applied. Test cases still fail due to missing tables.

2018-04-06 16:39:56 jdbc[3]:
//stat15.execute(“update play_evolutions set state = ‘applied’ where id = 1”);
2018-04-06 16:39:56 jdbc[3]: Table : potential plan item cost 10,210 index PUBLIC.PLAY_EVOLUTIONS.tableScan
2018-04-06 16:39:56 jdbc[3]: Table : potential plan item cost 230 index PUBLIC.PRIMARY_KEY_9
2018-04-06 16:39:56 lock: 3 shared read lock requesting for PLAY_EVOLUTIONS
2018-04-06 16:39:56 lock: 3 shared read lock ok PLAY_EVOLUTIONS
2018-04-06 16:39:56 jdbc[3]:
/SQL #:1 t:2/update play_evolutions set state = ‘applied’ where id = 1;
2018-04-06 16:39:56 lock: 3 shared read lock unlock PLAY_EVOLUTIONS
2018-04-06 16:39:56 jdbc[3]:
/
/stat4.close();
2018-04-06 16:39:56 jdbc[3]:

— insert fails in a test case…xx is deliberate —
//conn0.prepareStatement(“insert into “xx” (“name”,“description”,“type”,“xx”,“xx”,“xx”,“xx”,“xx”) values (?,?,?,?,?,?,?,?)”, new String[]{“id”});
2018-04-06 16:39:57 jdbc[3]:
/
/PreparedStatement prep1 = conn0.prepareStatement(“insert into “xx” (“name”,“description”,“type”,“xx”,“xx”,“xx”,“xx”,“xx”) values (?,?,?,?,?,?,?,?)”);
2018-04-06 16:39:57 jdbc[3]: exception
2018-04-06 16:39:57 jdbc[3]: exception
2018-04-06 16:39:57 jdbc[3]:


(Mohit Jaggi) #3

this was due to H2 capitalizing all names. used DATABASE_TO_UPPER=FALSE and the same script works for mysql and h2.
i wish debugging/logging was easier


(Rich Dougherty) #4

@mohitjaggi, sorry there is a very old issue about this but it hasn’t been fixed.

There are a variety of Evolutions issues that we’re hoping for community help with: https://github.com/playframework/playframework/issues?q=is%3Aissue+is%3Aopen+evolutions+label%3A"help+wanted"