Update for MySQL being broken (before 5.6?)

I think the schema was problematic but the Java code is OK and keeps
all the timestamps populated already.  Need to do some checking, but
looks OK at the moment.

[#46676015] UAA is broken with MySQL 5.1 (RDS)
Fix SQL generation scripts to match the hand made ones

[Fixes #46676015] UAA is broken with MySQL 5.1 (RDS)