From f10de2fc1061562907fa3f92493b9208379c028c Mon Sep 17 00:00:00 2001 From: Konstantin L Date: Thu, 15 Dec 2016 20:57:17 +0100 Subject: [PATCH 1/2] Respect database tables config. --- modules/system/classes/UpdateManager.php | 4 +-- .../migrations/2014_10_01_000010_Db_Jobs.php | 4 +-- .../2015_10_01_000018_Db_FailedJobs.php | 4 +-- ...6_10_01_000020_Db_System_Timestamp_Fix.php | 31 ++++++++++--------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php index 6e6948ece..61beb0a65 100644 --- a/modules/system/classes/UpdateManager.php +++ b/modules/system/classes/UpdateManager.php @@ -119,7 +119,7 @@ class UpdateManager */ public function update() { - $firstUp = !Schema::hasTable('migrations'); + $firstUp = !Schema::hasTable(config('database.migrations')); if ($firstUp) { $this->repository->createRepository(); $this->note('Migration table created'); @@ -337,7 +337,7 @@ class UpdateManager } } - Schema::dropIfExists('migrations'); + Schema::dropIfExists(config('database.migrations')); return $this; } 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 d00239bd7..95667596d 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 @@ -7,7 +7,7 @@ class DbJobs extends Migration { public function up() { - Schema::create('jobs', function (Blueprint $table) { + Schema::create(config('queue.connections.database.table'), function (Blueprint $table) { $table->engine = 'InnoDB'; $table->bigIncrements('id'); $table->string('queue'); @@ -22,6 +22,6 @@ class DbJobs extends Migration public function down() { - Schema::dropIfExists('jobs'); + Schema::dropIfExists(config('queue.connections.database.table')); } } 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 4c528d879..28ef6f1c5 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 @@ -7,7 +7,7 @@ class DbFailedJobs extends Migration { public function up() { - Schema::create('failed_jobs', function (Blueprint $table) { + Schema::create(config('queue.failed.table'), function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->text('connection'); @@ -19,6 +19,6 @@ class DbFailedJobs extends Migration public function down() { - Schema::dropIfExists('failed_jobs'); + Schema::dropIfExists(config('queue.failed.table')); } } 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 5a2c8d4a9..c4b2edfb5 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 @@ -10,24 +10,11 @@ use October\Rain\Database\Updates\Migration; */ class DbSystemTimestampFix extends Migration { - protected $coreTables = [ - 'deferred_bindings', - 'failed_jobs' => '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() { DbDongle::disableStrictMode(); - foreach ($this->coreTables as $table => $columns) { + foreach ($this->getCoreTables() as $table => $columns) { if (is_int($table)) { $table = $columns; $columns = ['created_at', 'updated_at']; @@ -41,4 +28,20 @@ class DbSystemTimestampFix extends Migration { // ... } + + private function getCoreTables() + { + return [ + 'deferred_bindings', + config('queue.failed.table') => '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', + ]; + } } From 2b5cf64ddf303499f4ee6a0bc6a0913539538693 Mon Sep 17 00:00:00 2001 From: Konstantin L Date: Tue, 10 Jan 2017 15:23:57 +0100 Subject: [PATCH 2/2] Use Config::get() instead of config() helper. --- modules/system/classes/UpdateManager.php | 4 ++-- .../system/database/migrations/2014_10_01_000010_Db_Jobs.php | 4 ++-- .../database/migrations/2015_10_01_000018_Db_FailedJobs.php | 4 ++-- .../migrations/2016_10_01_000020_Db_System_Timestamp_Fix.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php index 61beb0a65..b95e92fac 100644 --- a/modules/system/classes/UpdateManager.php +++ b/modules/system/classes/UpdateManager.php @@ -119,7 +119,7 @@ class UpdateManager */ public function update() { - $firstUp = !Schema::hasTable(config('database.migrations')); + $firstUp = !Schema::hasTable(Config::get('database.migrations')); if ($firstUp) { $this->repository->createRepository(); $this->note('Migration table created'); @@ -337,7 +337,7 @@ class UpdateManager } } - Schema::dropIfExists(config('database.migrations')); + Schema::dropIfExists(Config::get('database.migrations')); return $this; } 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 95667596d..681f61092 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 @@ -7,7 +7,7 @@ class DbJobs extends Migration { public function up() { - Schema::create(config('queue.connections.database.table'), function (Blueprint $table) { + Schema::create(Config::get('queue.connections.database.table'), function (Blueprint $table) { $table->engine = 'InnoDB'; $table->bigIncrements('id'); $table->string('queue'); @@ -22,6 +22,6 @@ class DbJobs extends Migration public function down() { - Schema::dropIfExists(config('queue.connections.database.table')); + Schema::dropIfExists(Config::get('queue.connections.database.table')); } } 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 28ef6f1c5..6c7887251 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 @@ -7,7 +7,7 @@ class DbFailedJobs extends Migration { public function up() { - Schema::create(config('queue.failed.table'), function (Blueprint $table) { + Schema::create(Config::get('queue.failed.table'), function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->text('connection'); @@ -19,6 +19,6 @@ class DbFailedJobs extends Migration public function down() { - Schema::dropIfExists(config('queue.failed.table')); + Schema::dropIfExists(Config::get('queue.failed.table')); } } 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 c4b2edfb5..794182f25 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 @@ -33,7 +33,7 @@ class DbSystemTimestampFix extends Migration { return [ 'deferred_bindings', - config('queue.failed.table') => 'failed_at', + Config::get('queue.failed.table') => 'failed_at', 'system_files', 'system_event_logs', 'system_mail_layouts',