-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove MySQL default value for timestamp #135
Comments
That MySQL timestamp handling is a mess. I'm not even sure what we can do. Mainly because MySQL treats different timestamps columns in the same table, e.g. the 1st instance will be automatically updated, but subsequent ones are not. This seems like a mess and for something for ruckusing to not get involved in. I just checked out the source for ActiveRecord 4.1.1 and they seem to skirt the whole issue by just unsupporting timestamp as a whole and telling users to use datetime and transparently re-writing timestamp definitions to datetime: Do you have any recommendations on how this should all be handled? On Jun 26, 2014, at 7:02 AM, Lars Nyström [email protected] wrote:
|
Summer vacation is over, so I guess it's time to answer here :) Rails has the advantage of controlling the entire application stack and can therefore deal with timezone conversions and such at the application level transparently. This is not possible with ruckusing. I'm mentioning that because timestamps are converted to UTC when being stored and then converted back to the timezone of the connection when retrieved. That's a wtf in itself, even though I guess there's some very bright idea behind it. When you google for the difference between timestamps and datetimes people tend to press the fact that timestamps represent a specific point in time, whereas a datetime represents a time like it's being displayed on a clock. That's a pretty weird explanation, but it makes more sense when you consider the fact that datetimes doesn't have a timezone component (a timestamp does implicitly, since you know it's UTC). However, since we can't control the way an application handles timezones through ruckusing this whole problem is left as an exercise for each developer to tackle. This means that there's really not much of a difference between timestamps and datetimes, besides date ranges. Still, I guess it's better to offer the possibility of using either of them with Ruckusing. (this answer is getting long now, I know). However, I still think that Ruckusing should define sane defaults for each column even though the developer leaves them out. When migrating from an RDBMS to another you would expect the migrations to produce equivalent schemas. Because Ruckusing is supposed to be database agnostic (at least that's my understanding of the project goal). So I'm still for overriding MySQLs defaults in this case. |
Thanks for the explanation. At this point I'm kind of confused as to what the solution should be. I'm reading this thread and its just a blob of "bleh" in my head. If I understand correctly, for MySQL when a
? E.g.
Right now generates a definition like:
But it should be over-ridden as in which MySQL ultimately generates:
Is that what you're saying? Here is my MySQL command line exploration:
|
I would prefer that. I think it's nice to provide sane defaults where the developer omitted them. The idea is to create the equivalent schemas on all different dbms if running the same method with ruckusing. In this case that requires us to override MySQL's defaults and provide our own. The alternative would be to override both SQLite and Postgres defaults to conform to MySQL's defaults. But I prefer the former option. Of course you could also close this ticket if you think this is outside of what ruckusing is actually about. The feature we're talking about is not about migrations between schemas, but between databases. On Fri, Sep 26, 2014 at 5:40 PM, Cody Caughlan [email protected]
|
I just noticed that one of my timestamp columns for a table created with ruckusing was set to
default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
, even though I never specified that through ruckusing. I then found what was going on in the MySQL Manual:Personally I think this is strange behaviour, and I guess this doesn't apply to Postegres or Sqlite. If that's the case I suggest that ruckusing overrides this behaviour so that a timestamp column gets the same default value no matter what database you are using.
The text was updated successfully, but these errors were encountered: