- if ($col['type'] == 'datetime' && isset($col['default']) && $col['default'] == 'CURRENT_TIMESTAMP') {
- $col['type'] = 'timestamp';
+
+ // Avoid invalid date errors in MySQL 5.7+
+ if ($col['type'] == 'timestamp' && !isset($col['default'])
+ && $version >= 50605) {
+ $col['default'] = 'CURRENT_TIMESTAMP';
+ }
+ if ($col['type'] == 'datetime') {
+ // Avoid invalid date errors in MySQL 5.7+
+ if (!isset($col['default']) && $version >= 50605) {
+ $col['default'] = 'CURRENT_TIMESTAMP';
+ }
+
+ // If we are using MySQL 5.5, convert datetime to timestamp if
+ // default value is CURRENT_TIMESTAMP. Not needed for MySQL 5.6+
+ // and MariaDB 10.0+
+ if (isset($col['default'])
+ && $col['default'] == 'CURRENT_TIMESTAMP'
+ && $version < 50605) {
+ $col['type'] = 'timestamp';
+ }