From 34f2aa7dcf21b41c8f9082c37018b33bf19109db Mon Sep 17 00:00:00 2001 From: Dave Shoreman Date: Tue, 26 Apr 2016 02:55:01 +0100 Subject: [PATCH 1/3] Switch to custom Schema facade Updates the Schema facade to point to the custom one added in the library repo, and sets all existing migrations to use our own Blueprint class instead of the one provided by the Laravel framework. --- .../migrations/2013_10_01_000001_Db_Backend_Users.php | 3 ++- .../migrations/2013_10_01_000002_Db_Backend_User_Groups.php | 3 ++- .../migrations/2013_10_01_000003_Db_Backend_Users_Groups.php | 3 ++- .../2013_10_01_000004_Db_Backend_User_Throttle.php | 3 ++- .../2014_01_04_000005_Db_Backend_User_Preferences.php | 3 ++- .../migrations/2014_10_01_000006_Db_Backend_Access_Log.php | 3 ++- .../2014_10_01_000007_Db_Backend_Add_Description_Field.php | 5 +++-- .../2015_10_01_000008_Db_Backend_Add_Superuser_Flag.php | 5 +++-- .../migrations/2014_10_01_000001_Db_Cms_Theme_Data.php | 3 ++- modules/system/aliases.php | 2 +- .../migrations/2013_10_01_000001_Db_Deferred_Bindings.php | 4 ++-- .../migrations/2013_10_01_000002_Db_System_Files.php | 4 ++-- .../2013_10_01_000003_Db_System_Plugin_Versions.php | 4 ++-- .../2013_10_01_000004_Db_System_Plugin_History.php | 3 ++- .../migrations/2013_10_01_000005_Db_System_Settings.php | 3 ++- .../migrations/2013_10_01_000006_Db_System_Parameters.php | 3 ++- .../2013_10_01_000007_Db_System_Add_Disabled_Flag.php | 5 +++-- .../2013_10_01_000008_Db_System_Mail_Templates.php | 4 ++-- .../migrations/2013_10_01_000009_Db_System_Mail_Layouts.php | 4 ++-- .../system/database/migrations/2014_10_01_000010_Db_Jobs.php | 3 ++- .../migrations/2014_10_01_000011_Db_System_Event_Logs.php | 4 ++-- .../migrations/2014_10_01_000012_Db_System_Request_Logs.php | 4 ++-- .../migrations/2014_10_01_000013_Db_System_Sessions.php | 4 ++-- .../2015_10_01_000014_Db_System_Mail_Layout_Rename.php | 1 + .../2015_10_01_000015_Db_System_Add_Frozen_Flag.php | 5 +++-- .../database/migrations/2015_10_01_000016_Db_Cache.php | 3 ++- .../migrations/2015_10_01_000017_Db_System_Revisions.php | 4 ++-- .../database/migrations/2015_10_01_000018_Db_FailedJobs.php | 3 ++- ...016_10_01_000019_Db_System_Plugin_History_Detail_Text.php | 5 +++-- 29 files changed, 61 insertions(+), 42 deletions(-) diff --git a/modules/backend/database/migrations/2013_10_01_000001_Db_Backend_Users.php b/modules/backend/database/migrations/2013_10_01_000001_Db_Backend_Users.php index 7cafbc2da..15069a180 100644 --- a/modules/backend/database/migrations/2013_10_01_000001_Db_Backend_Users.php +++ b/modules/backend/database/migrations/2013_10_01_000001_Db_Backend_Users.php @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('first_name')->nullable(); diff --git a/modules/backend/database/migrations/2013_10_01_000002_Db_Backend_User_Groups.php b/modules/backend/database/migrations/2013_10_01_000002_Db_Backend_User_Groups.php index 629bd8a53..f656ab296 100644 --- a/modules/backend/database/migrations/2013_10_01_000002_Db_Backend_User_Groups.php +++ b/modules/backend/database/migrations/2013_10_01_000002_Db_Backend_User_Groups.php @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('name')->unique('name_unique'); diff --git a/modules/backend/database/migrations/2013_10_01_000003_Db_Backend_Users_Groups.php b/modules/backend/database/migrations/2013_10_01_000003_Db_Backend_Users_Groups.php index 46be1218f..7d05e6bdb 100644 --- a/modules/backend/database/migrations/2013_10_01_000003_Db_Backend_Users_Groups.php +++ b/modules/backend/database/migrations/2013_10_01_000003_Db_Backend_Users_Groups.php @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->integer('user_id')->unsigned(); $table->integer('user_group_id')->unsigned(); diff --git a/modules/backend/database/migrations/2013_10_01_000004_Db_Backend_User_Throttle.php b/modules/backend/database/migrations/2013_10_01_000004_Db_Backend_User_Throttle.php index 34128dc23..866b3ccb9 100644 --- a/modules/backend/database/migrations/2013_10_01_000004_Db_Backend_User_Throttle.php +++ b/modules/backend/database/migrations/2013_10_01_000004_Db_Backend_User_Throttle.php @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->integer('user_id')->unsigned()->nullable()->index(); diff --git a/modules/backend/database/migrations/2014_01_04_000005_Db_Backend_User_Preferences.php b/modules/backend/database/migrations/2014_01_04_000005_Db_Backend_User_Preferences.php index a66e70761..513669ded 100644 --- a/modules/backend/database/migrations/2014_01_04_000005_Db_Backend_User_Preferences.php +++ b/modules/backend/database/migrations/2014_01_04_000005_Db_Backend_User_Preferences.php @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->integer('user_id')->unsigned(); diff --git a/modules/backend/database/migrations/2014_10_01_000006_Db_Backend_Access_Log.php b/modules/backend/database/migrations/2014_10_01_000006_Db_Backend_Access_Log.php index 859c7336e..1e2cb786c 100644 --- a/modules/backend/database/migrations/2014_10_01_000006_Db_Backend_Access_Log.php +++ b/modules/backend/database/migrations/2014_10_01_000006_Db_Backend_Access_Log.php @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->integer('user_id')->unsigned(); diff --git a/modules/backend/database/migrations/2014_10_01_000007_Db_Backend_Add_Description_Field.php b/modules/backend/database/migrations/2014_10_01_000007_Db_Backend_Add_Description_Field.php index d53c15036..273ce7096 100644 --- a/modules/backend/database/migrations/2014_10_01_000007_Db_Backend_Add_Description_Field.php +++ b/modules/backend/database/migrations/2014_10_01_000007_Db_Backend_Add_Description_Field.php @@ -1,12 +1,13 @@ string('code')->nullable()->index('code_index'); $table->text('description')->nullable(); $table->boolean('is_new_user_default')->default(false); @@ -15,7 +16,7 @@ class DbBackendAddDescriptionField extends Migration public function down() { - // Schema::table('backend_user_groups', function ($table) { + // Schema::table('backend_user_groups', function (Blueprint $table) { // $table->dropColumn('code'); // $table->dropColumn('description'); // $table->dropColumn('is_new_user_default'); diff --git a/modules/backend/database/migrations/2015_10_01_000008_Db_Backend_Add_Superuser_Flag.php b/modules/backend/database/migrations/2015_10_01_000008_Db_Backend_Add_Superuser_Flag.php index 71255096f..596d32080 100644 --- a/modules/backend/database/migrations/2015_10_01_000008_Db_Backend_Add_Superuser_Flag.php +++ b/modules/backend/database/migrations/2015_10_01_000008_Db_Backend_Add_Superuser_Flag.php @@ -1,5 +1,6 @@ boolean('is_superuser')->default(false); }); @@ -21,7 +22,7 @@ class DbBackendAddSuperuserFlag extends Migration public function down() { - // Schema::table('backend_users', function ($table) { + // Schema::table('backend_users', function (Blueprint $table) { // $table->dropColumn('is_superuser'); // }); } diff --git a/modules/cms/database/migrations/2014_10_01_000001_Db_Cms_Theme_Data.php b/modules/cms/database/migrations/2014_10_01_000001_Db_Cms_Theme_Data.php index ce5d53d2c..4f7cccd45 100644 --- a/modules/cms/database/migrations/2014_10_01_000001_Db_Cms_Theme_Data.php +++ b/modules/cms/database/migrations/2014_10_01_000001_Db_Cms_Theme_Data.php @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('theme')->nullable()->index(); diff --git a/modules/system/aliases.php b/modules/system/aliases.php index a746d484e..7071302d1 100644 --- a/modules/system/aliases.php +++ b/modules/system/aliases.php @@ -26,7 +26,6 @@ return [ 'Request' => Illuminate\Support\Facades\Request::class, 'Response' => Illuminate\Support\Facades\Response::class, 'Route' => Illuminate\Support\Facades\Route::class, - 'Schema' => Illuminate\Support\Facades\Schema::class, 'Session' => Illuminate\Support\Facades\Session::class, 'Storage' => Illuminate\Support\Facades\Storage::class, 'Url' => Illuminate\Support\Facades\URL::class, // Preferred @@ -52,6 +51,7 @@ return [ 'Ini' => October\Rain\Support\Facades\Ini::class, 'Twig' => October\Rain\Support\Facades\Twig::class, 'DbDongle' => October\Rain\Support\Facades\DbDongle::class, + 'Schema' => October\Rain\Support\Facades\Schema::class, 'Backend' => Backend\Facades\Backend::class, 'BackendMenu' => Backend\Facades\BackendMenu::class, 'BackendAuth' => Backend\Facades\BackendAuth::class, diff --git a/modules/system/database/migrations/2013_10_01_000001_Db_Deferred_Bindings.php b/modules/system/database/migrations/2013_10_01_000001_Db_Deferred_Bindings.php index 56de92f9c..68136bf56 100644 --- a/modules/system/database/migrations/2013_10_01_000001_Db_Deferred_Bindings.php +++ b/modules/system/database/migrations/2013_10_01_000001_Db_Deferred_Bindings.php @@ -1,13 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('master_type')->index(); diff --git a/modules/system/database/migrations/2013_10_01_000002_Db_System_Files.php b/modules/system/database/migrations/2013_10_01_000002_Db_System_Files.php index 97bee78c0..15e28ecc4 100644 --- a/modules/system/database/migrations/2013_10_01_000002_Db_System_Files.php +++ b/modules/system/database/migrations/2013_10_01_000002_Db_System_Files.php @@ -1,13 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('disk_name'); diff --git a/modules/system/database/migrations/2013_10_01_000003_Db_System_Plugin_Versions.php b/modules/system/database/migrations/2013_10_01_000003_Db_System_Plugin_Versions.php index 39e00fb4d..9253970e0 100644 --- a/modules/system/database/migrations/2013_10_01_000003_Db_System_Plugin_Versions.php +++ b/modules/system/database/migrations/2013_10_01_000003_Db_System_Plugin_Versions.php @@ -1,13 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('code')->index(); 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 94cc4a0f3..f4486b7e1 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 @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('code')->index(); diff --git a/modules/system/database/migrations/2013_10_01_000005_Db_System_Settings.php b/modules/system/database/migrations/2013_10_01_000005_Db_System_Settings.php index c76d12da0..0eb8b9040 100644 --- a/modules/system/database/migrations/2013_10_01_000005_Db_System_Settings.php +++ b/modules/system/database/migrations/2013_10_01_000005_Db_System_Settings.php @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('item')->nullable()->index(); diff --git a/modules/system/database/migrations/2013_10_01_000006_Db_System_Parameters.php b/modules/system/database/migrations/2013_10_01_000006_Db_System_Parameters.php index bb6887205..b87c62575 100644 --- a/modules/system/database/migrations/2013_10_01_000006_Db_System_Parameters.php +++ b/modules/system/database/migrations/2013_10_01_000006_Db_System_Parameters.php @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('namespace', 100); diff --git a/modules/system/database/migrations/2013_10_01_000007_Db_System_Add_Disabled_Flag.php b/modules/system/database/migrations/2013_10_01_000007_Db_System_Add_Disabled_Flag.php index 5c98a6f6a..15fdedb07 100644 --- a/modules/system/database/migrations/2013_10_01_000007_Db_System_Add_Disabled_Flag.php +++ b/modules/system/database/migrations/2013_10_01_000007_Db_System_Add_Disabled_Flag.php @@ -1,19 +1,20 @@ boolean('is_disabled')->default(0); }); } public function down() { - Schema::table('system_plugin_versions', function ($table) { + Schema::table('system_plugin_versions', function (Blueprint $table) { $table->dropColumn('is_disabled'); }); } diff --git a/modules/system/database/migrations/2013_10_01_000008_Db_System_Mail_Templates.php b/modules/system/database/migrations/2013_10_01_000008_Db_System_Mail_Templates.php index d761c0107..82b9b4bc0 100644 --- a/modules/system/database/migrations/2013_10_01_000008_Db_System_Mail_Templates.php +++ b/modules/system/database/migrations/2013_10_01_000008_Db_System_Mail_Templates.php @@ -1,13 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('code')->nullable(); diff --git a/modules/system/database/migrations/2013_10_01_000009_Db_System_Mail_Layouts.php b/modules/system/database/migrations/2013_10_01_000009_Db_System_Mail_Layouts.php index 9866f54d1..d7707b736 100644 --- a/modules/system/database/migrations/2013_10_01_000009_Db_System_Mail_Layouts.php +++ b/modules/system/database/migrations/2013_10_01_000009_Db_System_Mail_Layouts.php @@ -1,13 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('name')->nullable(); diff --git a/modules/system/database/migrations/2014_10_01_000010_Db_Jobs.php b/modules/system/database/migrations/2014_10_01_000010_Db_Jobs.php index aa558ce20..d00239bd7 100644 --- a/modules/system/database/migrations/2014_10_01_000010_Db_Jobs.php +++ b/modules/system/database/migrations/2014_10_01_000010_Db_Jobs.php @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->bigIncrements('id'); $table->string('queue'); diff --git a/modules/system/database/migrations/2014_10_01_000011_Db_System_Event_Logs.php b/modules/system/database/migrations/2014_10_01_000011_Db_System_Event_Logs.php index 404ec8cf5..500b1a400 100644 --- a/modules/system/database/migrations/2014_10_01_000011_Db_System_Event_Logs.php +++ b/modules/system/database/migrations/2014_10_01_000011_Db_System_Event_Logs.php @@ -1,13 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->string('level')->nullable()->index(); diff --git a/modules/system/database/migrations/2014_10_01_000012_Db_System_Request_Logs.php b/modules/system/database/migrations/2014_10_01_000012_Db_System_Request_Logs.php index 009ebec15..15a4524d1 100644 --- a/modules/system/database/migrations/2014_10_01_000012_Db_System_Request_Logs.php +++ b/modules/system/database/migrations/2014_10_01_000012_Db_System_Request_Logs.php @@ -1,13 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->integer('status_code')->nullable(); diff --git a/modules/system/database/migrations/2014_10_01_000013_Db_System_Sessions.php b/modules/system/database/migrations/2014_10_01_000013_Db_System_Sessions.php index 4981b81f5..f229534cf 100644 --- a/modules/system/database/migrations/2014_10_01_000013_Db_System_Sessions.php +++ b/modules/system/database/migrations/2014_10_01_000013_Db_System_Sessions.php @@ -1,10 +1,10 @@ string('id')->unique(); $table->text('payload')->nullable(); $table->integer('last_activity')->nullable(); diff --git a/modules/system/database/migrations/2015_10_01_000014_Db_System_Mail_Layout_Rename.php b/modules/system/database/migrations/2015_10_01_000014_Db_System_Mail_Layout_Rename.php index 7102c02c8..a89063f78 100644 --- a/modules/system/database/migrations/2015_10_01_000014_Db_System_Mail_Layout_Rename.php +++ b/modules/system/database/migrations/2015_10_01_000014_Db_System_Mail_Layout_Rename.php @@ -1,6 +1,7 @@ boolean('is_frozen')->default(0); }); } public function down() { - Schema::table('system_plugin_versions', function ($table) { + Schema::table('system_plugin_versions', function (Blueprint $table) { $table->dropColumn('is_frozen'); }); } diff --git a/modules/system/database/migrations/2015_10_01_000016_Db_Cache.php b/modules/system/database/migrations/2015_10_01_000016_Db_Cache.php index 357e5ff16..6918cd03e 100644 --- a/modules/system/database/migrations/2015_10_01_000016_Db_Cache.php +++ b/modules/system/database/migrations/2015_10_01_000016_Db_Cache.php @@ -1,12 +1,13 @@ string('key')->unique(); $table->text('value'); $table->integer('expiration'); diff --git a/modules/system/database/migrations/2015_10_01_000017_Db_System_Revisions.php b/modules/system/database/migrations/2015_10_01_000017_Db_System_Revisions.php index 7796a5261..a53abd9e4 100644 --- a/modules/system/database/migrations/2015_10_01_000017_Db_System_Revisions.php +++ b/modules/system/database/migrations/2015_10_01_000017_Db_System_Revisions.php @@ -1,13 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->integer('user_id')->unsigned()->nullable()->index(); 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 bff427a64..0d72b40ac 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 @@ -1,12 +1,13 @@ engine = 'InnoDB'; $table->increments('id'); $table->text('connection'); 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 247694d15..a63c1babb 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 @@ -1,19 +1,20 @@ text('detail')->nullable()->change(); }); } public function down() { - Schema::table('system_plugin_history', function ($table) { + Schema::table('system_plugin_history', function (Blueprint $table) { $table->string('detail')->nullable()->change(); }); } From 48090351bd83f91109ab9758437e9d687ee523ec Mon Sep 17 00:00:00 2001 From: Dave Shoreman Date: Tue, 26 Apr 2016 12:09:07 +0100 Subject: [PATCH 2/3] Convert current core timestamp columns to nullable Adds migrations to switch all existing timestamp fields from being NOT NULL DEFAULT 0, to NULL DEFAULT NULL, in order to get around issues with new default modes in MySQL that cause errors in 0 dates. --- ..._10_01_000009_Db_Backend_Timestamp_Fix.php | 28 +++++++++++++ ...2016_10_01_000002_Db_Cms_Timestamp_Fix.php | 19 +++++++++ ...10_01_000003_Db_System_Plugin_Versions.php | 2 +- ..._10_01_000004_Db_System_Plugin_History.php | 2 +- .../2015_10_01_000018_Db_FailedJobs.php | 2 +- ...6_10_01_000020_Db_System_Timestamp_Fix.php | 40 +++++++++++++++++++ 6 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 modules/backend/database/migrations/2016_10_01_000009_Db_Backend_Timestamp_Fix.php create mode 100644 modules/cms/database/migrations/2016_10_01_000002_Db_Cms_Timestamp_Fix.php create mode 100644 modules/system/database/migrations/2016_10_01_000020_Db_System_Timestamp_Fix.php 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() + { + // ... + } +} From e2b110a611ea60e0a2070eccb3f497a5de68061f Mon Sep 17 00:00:00 2001 From: Dave Shoreman Date: Fri, 29 Apr 2016 18:39:26 +0100 Subject: [PATCH 3/3] Disable strict mode before running migrations This will ensure strict mode is not applied while running migrations for both modules and plugins, either when installing or removing. We don't need to call disableStrictMode from UpdateManager::uninstall() as it is called within the plugin removal methods, which are run first. To force strict mode to be enabled, set 'strict' => true in the database config. --- modules/system/classes/UpdateManager.php | 2 ++ modules/system/classes/VersionManager.php | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php index 206e4beae..88ee66fae 100644 --- a/modules/system/classes/UpdateManager.php +++ b/modules/system/classes/UpdateManager.php @@ -366,6 +366,8 @@ class UpdateManager */ public function migrateModule($module) { + DbDongle::disableStrictMode(); + $this->migrator->run(base_path() . '/modules/'.strtolower($module).'/database/migrations'); $this->note($module); diff --git a/modules/system/classes/VersionManager.php b/modules/system/classes/VersionManager.php index 05576e27e..a37019338 100644 --- a/modules/system/classes/VersionManager.php +++ b/modules/system/classes/VersionManager.php @@ -385,6 +385,8 @@ class VersionManager */ protected function applyDatabaseScript($code, $version, $script) { + DbDongle::disableStrictMode(); + /* * Execute the database PHP script */ @@ -405,6 +407,8 @@ class VersionManager */ protected function removeDatabaseScript($code, $version, $script) { + DbDongle::disableStrictMode(); + /* * Execute the database PHP script */