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 index 22fd973b8..99fde4cce 100644 --- 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 @@ -2,6 +2,12 @@ use October\Rain\Database\Updates\Migration; +/** + * This migration addresses a MySQL specific issue around STRICT MODE. + * In past versions, Laravel would give timestamps a bad default value + * of "0" considered invalid by MySQL. Strict mode is disabled and the + * the timestamps are patched up. Credit for this work: Dave Shoreman. + */ class DbBackendTimestampFix extends Migration { protected $backendTables = [ @@ -12,9 +18,7 @@ class DbBackendTimestampFix extends Migration 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=''"); + DbDongle::disableStrictMode(); foreach ($this->backendTables as $table) { DbDongle::convertTimestamps($table); 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 index 5a11deb0a..327640e68 100644 --- 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 @@ -2,13 +2,18 @@ use October\Rain\Database\Updates\Migration; +/** + * This migration addresses a MySQL specific issue around STRICT MODE. + * In past versions, Laravel would give timestamps a bad default value + * of "0" considered invalid by MySQL. Strict mode is disabled and the + * the timestamps are patched up. Credit for this work: Dave Shoreman. + */ class DbCmsTimestampFix extends Migration { 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=''"); + DbDongle::disableStrictMode(); + DbDongle::convertTimestamps('cms_theme_data'); } diff --git a/modules/system/database/migrations/2016_10_01_000019_Db_System_Plugin_History_Detail_Text.php b/modules/system/database/migrations/2016_10_01_000019_Db_System_Plugin_History_Detail_Text.php index a63c1babb..4334a1c13 100644 --- a/modules/system/database/migrations/2016_10_01_000019_Db_System_Plugin_History_Detail_Text.php +++ b/modules/system/database/migrations/2016_10_01_000019_Db_System_Plugin_History_Detail_Text.php @@ -7,6 +7,9 @@ class DbSystemPluginHistoryDetailText extends Migration { public function up() { + // Migration occurs before timestamps are patched (see next migration) + DbDongle::disableStrictMode(); + Schema::table('system_plugin_history', function (Blueprint $table) { $table->text('detail')->nullable()->change(); }); 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 index a42fbea54..5a2c8d4a9 100644 --- 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 @@ -2,6 +2,12 @@ use October\Rain\Database\Updates\Migration; +/** + * This migration addresses a MySQL specific issue around STRICT MODE. + * In past versions, Laravel would give timestamps a bad default value + * of "0" considered invalid by MySQL. Strict mode is disabled and the + * the timestamps are patched up. Credit for this work: Dave Shoreman. + */ class DbSystemTimestampFix extends Migration { protected $coreTables = [ @@ -19,9 +25,7 @@ class DbSystemTimestampFix extends Migration 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=''"); + DbDongle::disableStrictMode(); foreach ($this->coreTables as $table => $columns) { if (is_int($table)) {