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

Explicitly set UpdateTime to update to current time on a change to the row #28

Merged
merged 4 commits into from Feb 24, 2017

Conversation

gregcorbett
Copy link
Member

In MySQL 5.1,

The first TIMESTAMP column in a table, if not declared with the NULL attribute or an explicit DEFAULT or ON UPDATE clause, is automatically assigned the DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP attributes.

In MySQL 5.6.6+ (the version used for Indigo DataCloud), this does not happen.

No TIMESTAMP column is assigned the DEFAULT CURRENT_TIMESTAMP or ON UPDATE CURRENT_TIMESTAMP attributes automatically. Those attributes must be explicitly specified."

See here for the MySQL documentation referring to this.

This PR explicitly specifies NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP for all columns called UpdateTime, and provides an update_schema.sql file to upgrade any existing databases. Any NULL time stamps will be set to CURRENT_TIMESTAMP when update_schema.sql is applied.

Once this PR is applied, UpdateTime will now explicitly update on 5.6.6+ as it does on implicitly on 5.1

- to upgrade exisiting instances to the new timestamp default
- any null timestamps get set to now
Copy link
Member

@tofu-rocketry tofu-rocketry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine.

@gregcorbett gregcorbett merged commit 36a3748 into apel:dev Feb 24, 2017
@gregcorbett gregcorbett deleted the updatetime_bug_fix branch February 24, 2017 09:46
@gregcorbett gregcorbett restored the updatetime_bug_fix branch February 24, 2017 09:47
@gregcorbett gregcorbett deleted the updatetime_bug_fix branch March 29, 2017 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants