I was adding a table to a mySQL db and three of my columns were of type ‘TIMESTAMP’. After starting up my grails project in the production environment, the liquibase updates were made to the db. I was inspecting the generated table and columns after this and I was surprised to see that the timestamp columns had information that I hadn’t given to them in changelog.xml. Namely:
became:
| Field | Type | Null | Key| Default | Extra |
LAST_UPDATED | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP
and
became
| Field | Type | Null | Key| Default | Extra |
DATE_CREATED | timestamp | NO | | 0000-00-00 00:00:00 | |
Where did the default and extra data come from for these columns? Did grails add this somehow or is it a feature of liquibase or something else?
It would not surprise me if Grails did some updates to your schema for you, but I can say for sure that I’ve never seen extra, unexpected attributes added by Liquibase. I think Grails does have some “smarts” under the hood that will cause it to apply various attributes to a schema based on the definition of your model objects.
Forgot to also mention that I am running ant through eclipse, and it is not a grails project, but rather a spring mvc/java project, though I am merely running the liquibase ant tasks.
* Running mysql-5.1.54-x64, Win 7 * InnoDB is the default engine
– Liquibase –
– Liquibase SQL output – created TIMESTAMP NOT NULL, last_updated_date_time TIMESTAMP NOT NULL
– When SQL is run for the table creation – Field, Type, Null, Key, Default, Extra ’created’, ‘timestamp’, ‘NO’, ‘’, ‘CURRENT_TIMESTAMP’, ‘on update CURRENT_TIMESTAMP’ ‘last_updated_date_time’, ‘timestamp’, ‘NO’, ‘’, ‘0000-00-00 00:00:00’, ''
Perhaps this is a MySQL/InnoDB bug? I tried again with 3 timestamps, and the first always defaults to CURRENT_TIMESTAMP and the subsequent timestamps all have 0000-00-00 in them.