Skip to content

Commit

Permalink
Improve compatibility of removeZeroDates migration
Browse files Browse the repository at this point in the history
Some MySQL versions (confirmed on 5.7.17) error immediately on any
UPDATE that even includes a "zero" date in the WHERE clause. IGNORE is
required to make the query execute.

(cherry picked from commit d583ac0)
  • Loading branch information
zerocrates committed Apr 12, 2017
1 parent f227dea commit ccc5b93
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions application/migrations/20151209103299_removeZeroDates.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class removeZeroDates extends Omeka_Db_Migration_AbstractMigration
{
public function up()
{
$this->db->query("UPDATE {$this->db->Collection} SET `added` = '2000-01-01 00:00:00' WHERE `added` = '0000-00-00 00:00:00'");
$this->db->query("UPDATE {$this->db->Collection} SET `modified` = '2000-01-01 00:00:00' WHERE `modified` = '0000-00-00 00:00:00'");
$this->db->query("UPDATE {$this->db->File} SET `added` = '2000-01-01 00:00:00' WHERE `added` = '0000-00-00 00:00:00'");
$this->db->query("UPDATE {$this->db->Item} SET `added` = '2000-01-01 00:00:00' WHERE `added` = '0000-00-00 00:00:00'");
$this->db->query("UPDATE {$this->db->Process} SET `started` = '2000-01-01 00:00:00' WHERE `started` = '0000-00-00 00:00:00'");
$this->db->query("UPDATE {$this->db->Process} SET `stopped` = '2000-01-01 00:00:00' WHERE `stopped` = '0000-00-00 00:00:00'");
$this->db->query("UPDATE IGNORE {$this->db->Collection} SET `added` = '2000-01-01 00:00:00' WHERE `added` = '0000-00-00 00:00:00'");
$this->db->query("UPDATE IGNORE {$this->db->Collection} SET `modified` = '2000-01-01 00:00:00' WHERE `modified` = '0000-00-00 00:00:00'");
$this->db->query("UPDATE IGNORE {$this->db->File} SET `added` = '2000-01-01 00:00:00' WHERE `added` = '0000-00-00 00:00:00'");
$this->db->query("UPDATE IGNORE {$this->db->Item} SET `added` = '2000-01-01 00:00:00' WHERE `added` = '0000-00-00 00:00:00'");
$this->db->query("UPDATE IGNORE {$this->db->Process} SET `started` = '2000-01-01 00:00:00' WHERE `started` = '0000-00-00 00:00:00'");
$this->db->query("UPDATE IGNORE {$this->db->Process} SET `stopped` = '2000-01-01 00:00:00' WHERE `stopped` = '0000-00-00 00:00:00'");
}
}

0 comments on commit ccc5b93

Please sign in to comment.