Skip to content

Commit 53097eb

Browse files
martinssipenkoderrabus
authored andcommitted
[Lock] create lock table if it does not exist
1 parent 5a63cb6 commit 53097eb

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Store/DoctrineDbalStore.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\DBAL\Connection;
1515
use Doctrine\DBAL\DriverManager;
1616
use Doctrine\DBAL\Exception as DBALException;
17+
use Doctrine\DBAL\Exception\TableNotFoundException;
1718
use Doctrine\DBAL\ParameterType;
1819
use Doctrine\DBAL\Schema\Schema;
1920
use Symfony\Component\Lock\Exception\InvalidArgumentException;
@@ -90,6 +91,9 @@ public function save(Key $key)
9091
ParameterType::STRING,
9192
ParameterType::STRING,
9293
]);
94+
} catch (TableNotFoundException $e) {
95+
$this->createTable();
96+
$this->save($key);
9397
} catch (DBALException $e) {
9498
// the lock is already acquired. It could be us. Let's try to put off.
9599
$this->putOffExpiration($key, $this->initialTtl);

Tests/Store/DoctrineDbalStoreTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public function testDsn(string $dsn, string $file = null)
7070

7171
try {
7272
$store = new DoctrineDbalStore($dsn);
73-
$store->createTable();
7473

7574
$store->save($key);
7675
$this->assertTrue($store->exists($key));

Tests/Store/PdoStoreTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public function testDsn(string $dsn, string $file = null)
8484

8585
try {
8686
$store = new PdoStore($dsn);
87-
$store->createTable();
8887

8988
$store->save($key);
9089
$this->assertTrue($store->exists($key));

0 commit comments

Comments
 (0)