Skip to content

Commit ea163d7

Browse files
Add cache_locks table for the database cache driver (#1561)
1 parent 4ab9e5a commit ea163d7

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
use Winter\Storm\Database\Schema\Blueprint;
4+
5+
return new class extends \Winter\Storm\Database\Updates\Migration
6+
{
7+
public function up()
8+
{
9+
$schema = Schema::connection($this->getLockConnection());
10+
11+
if ($schema->hasTable($this->getTableName())) {
12+
return;
13+
}
14+
15+
$schema->create($this->getTableName(), function (Blueprint $table) {
16+
$table->string('key')->primary();
17+
$table->string('owner');
18+
$table->bigInteger('expiration')->index();
19+
});
20+
}
21+
22+
public function down()
23+
{
24+
Schema::connection($this->getLockConnection())->dropIfExists($this->getTableName());
25+
}
26+
27+
protected function getLockConnection()
28+
{
29+
return Config::get('cache.stores.database.lock_connection')
30+
?? Config::get('cache.stores.database.connection');
31+
}
32+
33+
protected function getTableName()
34+
{
35+
return Config::get('cache.stores.database.lock_table', 'cache_locks');
36+
}
37+
};

0 commit comments

Comments
 (0)