Skip to content
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

Timestamp columns created incorrectly #97

Open
tindzk opened this issue May 10, 2016 · 4 comments
Open

Timestamp columns created incorrectly #97

tindzk opened this issue May 10, 2016 · 4 comments

Comments

@tindzk
Copy link
Collaborator

tindzk commented May 10, 2016

Consider a table with the following two columns:

val created  = column[Timestamp]("created")
val modified = column[Timestamp]("modified")

SHOW CREATE TABLE TableName shows that the columns were created as follows:

`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
`modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'

Neither of the two columns should have a default value or update the timestamp automatically.

@mkotsbak
Copy link

That is probably because of MySQL's "fun" automagic TIMESTAMP type. It is expected. Maybe it should be mapped to the less magic DATETIME type?

@darkfrog26
Copy link
Contributor

@mkotsbak, the only problem I have with using DATETIME is that it requires 8 bytes instead of 4 bytes, but that's hardly a big deal and given the confusion dealing with TIMESTAMP it seems a perfectly acceptable trade-off.

@mkotsbak
Copy link

Ah, didnt know that difference. Is it for storing the timezone?

@darkfrog26
Copy link
Contributor

This is a worthwhile read comparing the distinctions: http://infopotato.com/blog/index/datetime_vs_timestamp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants