Blog

Loading Time Zone tables for MySQL in Travis CI

Background

Like many teams, we use Travis CI for testing and deploying builds on various projects.

While working on upgrading the Django version from 1.5 to 1.6 on a project, we began seeing test failures in Travis around date queries.

The Issue

We realized that this was a side effect of the new behavior of date lookups in Django. Django 1.6 shipped with time zone aware day, month, and week_day lookups. Previously, these lookups were all done in UTC.

The caveat with these new lookups is that the time zone tables in your MySQL database need to be populated.

These tables need to be manually loaded in your Travis environment database during your build run.

The Fix

MySQL docs list various steps to populate these tables.

For Travis, simply add this command to your before_script config:


before_script:
- mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql