-
Notifications
You must be signed in to change notification settings - Fork 202
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
Ensure MySQL data supports timezones #1840
Conversation
This addresses various timezone issues, that don't exist with the pgsql schema.
Tests with the dataset of a large user: table-sizes.txt Schema was upgraded to
Same test with an older MySQL version:
All tests ran on my notebook. |
@Thomas-Gelf Opinions? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lazyfrosch: thanks for tackling this, but please go for BIGINT/msec's as proposed in #58 - that way we are completely independent from DB specific issues
@lazyfrosch: please see related mail, afterwards feel free to finalize/merge this. Thanks for the good work! |
Added a commit for disabling Ready for merge after CI. |
@lazyfrosch the mysql migration doesn't work for us using MySQL 5.6 Enterprise Edition:
Using a dump of the same database in the icinga standalone vagrant box with MariaDB 5.5.60 works. |
I heard about some corner case with MySQL 5.6. Will look into it, a small adjustment to the migration should be all needed. |
Interesting, a fresh schema in MySQL 5.6 with migration works fine... @friesoft just to be sure, could you get me this for your current schema: DESC director_activity_log;
SHOW CREATE TABLE director_activity_log \G You could also try this migration: (note the extra default values with NOT NULL)
|
Ah I found the problem, ignore the suggestion above |
The correct migration is: SET sql_mode = 'STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,ANSI_QUOTES,ERROR_FOR_DIVISION_BY_ZERO';
ALTER TABLE director_activity_log
MODIFY change_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE director_deployment_log
MODIFY start_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY end_time TIMESTAMP NULL DEFAULT NULL,
MODIFY abort_time TIMESTAMP NULL DEFAULT NULL;
ALTER TABLE director_schema_migration
MODIFY migration_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE director_job
MODIFY ts_last_attempt TIMESTAMP NULL DEFAULT NULL,
MODIFY ts_last_error TIMESTAMP NULL DEFAULT NULL;
ALTER TABLE import_source
MODIFY last_attempt TIMESTAMP NULL DEFAULT NULL;
ALTER TABLE import_run
MODIFY start_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY end_time TIMESTAMP NULL DEFAULT NULL;
ALTER TABLE sync_rule
MODIFY last_attempt TIMESTAMP NULL DEFAULT NULL;
ALTER TABLE sync_run
MODIFY start_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; @friesoft appreciate your feedback! |
MySQL 5.6 won't accept NULL defaults with NOT NULL... refs #1840
@lazyfrosch works 😃 Thanks for the fast fix 👍 |
This migrates all DATETIME to TIMESTAMP in MySQL, so we support timezones and every timestamp can be correctly converted between UTC (storage) and local timezone of the user.
Only affects MySQL
max_execution_time
for migrationsAffects the following tables:
fixes #1332
fixes #1813
Manual installation
This fix will be released with 1.7.0 and not backported to an earlier version.
If you currently experience problems with timezones, you can apply the schema migration manually like this:
Make a mysqldump backup before starting with the changes*
After this apply the
ALTER TABLE
statements manually:Depending on your database size, this can take up to a few minutes.
WARNING: Do not change anything in the
director_schema_migration
table.When you upgrade to >= 1.7 at a later date the normal schema migration will be run again, but since the table columns are already in the correct format, it won't change anything and should not fail.
ref/IP/13765
ref/IP/13087