Reputation: 168
I want to add a "dateCreated" field to an object that is already exiting, and the corresponding table already has several objects in it. When the dateCreated timestamp column is added the timestamp is set to '0000-00-00 00:00:00', but I need to set it to the actual dateCreated value that I call when I am at the groovy/grails level.
Is there a way to populate the new column with the correct 'dateCreated' value?
Upvotes: 0
Views: 283
Reputation: 371
You may possibly be able to do this by setting a default value for the dateCreated field in your domain class?
eg.
class ExistingDomainObject {
Date dateCreated = someFunctionToCalculateCorrectDateCreated()
}
Upvotes: 1