diff --git a/modules/backend/database/migrations/2016_10_01_000009_Db_Backend_Timestamp_Fix.php b/modules/backend/database/migrations/2016_10_01_000009_Db_Backend_Timestamp_Fix.php new file mode 100644 index 000000000..77f0d3b40 --- /dev/null +++ b/modules/backend/database/migrations/2016_10_01_000009_Db_Backend_Timestamp_Fix.php @@ -0,0 +1,28 @@ +backendTables as $table) { + DbDongle::convertTimestamps($table); + } + } + + public function down() + { + // ... + } +} diff --git a/modules/cms/database/migrations/2016_10_01_000002_Db_Cms_Timestamp_Fix.php b/modules/cms/database/migrations/2016_10_01_000002_Db_Cms_Timestamp_Fix.php new file mode 100644 index 000000000..5a11deb0a --- /dev/null +++ b/modules/cms/database/migrations/2016_10_01_000002_Db_Cms_Timestamp_Fix.php @@ -0,0 +1,19 @@ +increments('id'); $table->string('code')->index(); $table->string('version', 50); - $table->timestamp('created_at'); + $table->timestamp('created_at')->nullable(); }); } diff --git a/modules/system/database/migrations/2013_10_01_000004_Db_System_Plugin_History.php b/modules/system/database/migrations/2013_10_01_000004_Db_System_Plugin_History.php index f4486b7e1..0bf14b54d 100644 --- a/modules/system/database/migrations/2013_10_01_000004_Db_System_Plugin_History.php +++ b/modules/system/database/migrations/2013_10_01_000004_Db_System_Plugin_History.php @@ -14,7 +14,7 @@ class DbSystemPluginHistory extends Migration $table->string('type', 20)->index(); $table->string('version', 50); $table->string('detail')->nullable(); - $table->timestamp('created_at'); + $table->timestamp('created_at')->nullable(); }); } diff --git a/modules/system/database/migrations/2015_10_01_000018_Db_FailedJobs.php b/modules/system/database/migrations/2015_10_01_000018_Db_FailedJobs.php index 0d72b40ac..4c528d879 100644 --- a/modules/system/database/migrations/2015_10_01_000018_Db_FailedJobs.php +++ b/modules/system/database/migrations/2015_10_01_000018_Db_FailedJobs.php @@ -13,7 +13,7 @@ class DbFailedJobs extends Migration $table->text('connection'); $table->text('queue'); $table->text('payload'); - $table->timestamp('failed_at'); + $table->timestamp('failed_at')->nullable(); }); } diff --git a/modules/system/database/migrations/2016_10_01_000020_Db_System_Timestamp_Fix.php b/modules/system/database/migrations/2016_10_01_000020_Db_System_Timestamp_Fix.php new file mode 100644 index 000000000..a42fbea54 --- /dev/null +++ b/modules/system/database/migrations/2016_10_01_000020_Db_System_Timestamp_Fix.php @@ -0,0 +1,40 @@ + 'failed_at', + 'system_files', + 'system_event_logs', + 'system_mail_layouts', + 'system_mail_templates', + 'system_plugin_history' => 'created_at', + 'system_plugin_versions' => 'created_at', + 'system_request_logs', + 'system_revisions', + ]; + + public function up() + { + // Disable all special modes such as NO_ZERO_DATE to prevent any + // errors from MySQL before we can update the timestamp columns. + Db::statement("SET @@SQL_MODE=''"); + + foreach ($this->coreTables as $table => $columns) { + if (is_int($table)) { + $table = $columns; + $columns = ['created_at', 'updated_at']; + } + + DbDongle::convertTimestamps($table, $columns); + } + } + + public function down() + { + // ... + } +}