cakephp / cakephp/phinx

Daylight Savings Issues

Open
#513 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

Phinx has an issue with mysql and daylight savings. My server is set to PST and mysql is using SYSTEM time for both global/session.

When running the migrations I hit this error:
ERROR 1292 (22007): Incorrect datetime value: '2015-03-08 02:01:13' for column 'start_time' at row 1

What's happening is that phinx is trying to insert this value into phinxlog using php's time() function, which is set to UTC. So, my PST mysql server receives the timestamp '2015-03-08 02:01:13', but then throws an error because that hour does not exist for PST on March 8th.

https://github.com/robmorgan/phinx/blob/0.4.x-dev/src/Phinx/Migration/Manager/Environment.php#L90

It's weird that phinx does this, since the column in question is set to use CURRENT_TIMESTAMP by default (and `on update CURRENT_TIMESTAMP). If the time still needs to be inserted manually, then it should be made timezone aware in php to compensate.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Phinx/Migration/Manager/Environment.php around line 90 and inspect how the migration log timestamp is generated and inserted. Reproduce the migration with MySQL using SYSTEM time in PST around the March 8 daylight-saving transition. Done means the migration log accepts the timestamp and the migration completes without the reported invalid datetime error.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.