diff --git a/config/static_caching.php b/config/static_caching.php index e190b9729d..3e4e5fe6e5 100644 --- a/config/static_caching.php +++ b/config/static_caching.php @@ -125,6 +125,8 @@ 'nocache' => 'cache', + 'nocache_db_connection' => env('STATAMIC_NOCACHE_DB_CONNECTION'), + 'nocache_js_position' => 'body', /* diff --git a/src/Console/Commands/stubs/statamic_nocache_tables.php.stub b/src/Console/Commands/stubs/statamic_nocache_tables.php.stub index dc59f5a6c4..4d17f65063 100644 --- a/src/Console/Commands/stubs/statamic_nocache_tables.php.stub +++ b/src/Console/Commands/stubs/statamic_nocache_tables.php.stub @@ -8,7 +8,9 @@ class StatamicNocacheTables extends Migration { public function up() { - Schema::create('NOCACHE_TABLE', function (Blueprint $table) { + Schema::connection( + config('statamic.static_caching.nocache_db_connection') + )->create('NOCACHE_TABLE', function (Blueprint $table) { $table->string('key')->index()->primary(); $table->string('url')->index(); $table->longText('region'); @@ -18,6 +20,8 @@ class StatamicNocacheTables extends Migration public function down() { - Schema::dropIfExists('nocache_regions'); + Schema::connection( + config('statamic.static_caching.nocache_db_connection') + )->dropIfExists('NOCACHE_TABLE'); } } diff --git a/src/StaticCaching/NoCache/DatabaseRegion.php b/src/StaticCaching/NoCache/DatabaseRegion.php index a5f0b50330..7eac212087 100644 --- a/src/StaticCaching/NoCache/DatabaseRegion.php +++ b/src/StaticCaching/NoCache/DatabaseRegion.php @@ -15,4 +15,9 @@ class DatabaseRegion extends Model protected $casts = [ 'key' => 'string', ]; + + public function getConnectionName() + { + return config('statamic.static_caching.nocache_db_connection') ?: parent::getConnectionName(); + } }