diff --git a/src/Symfony/Component/Lock/Store/DoctrineDbalStore.php b/src/Symfony/Component/Lock/Store/DoctrineDbalStore.php index ead96843fbb78..1a94f3fc64711 100644 --- a/src/Symfony/Component/Lock/Store/DoctrineDbalStore.php +++ b/src/Symfony/Component/Lock/Store/DoctrineDbalStore.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Exception as DBALException; +use Doctrine\DBAL\Exception\TableNotFoundException; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\Schema; use Symfony\Component\Lock\Exception\InvalidArgumentException; @@ -90,6 +91,9 @@ public function save(Key $key) ParameterType::STRING, ParameterType::STRING, ]); + } catch (TableNotFoundException $e) { + $this->createTable(); + $this->save($key); } catch (DBALException $e) { // the lock is already acquired. It could be us. Let's try to put off. $this->putOffExpiration($key, $this->initialTtl); diff --git a/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalStoreTest.php index c20e2d3088111..6a89e49399b0c 100644 --- a/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/DoctrineDbalStoreTest.php @@ -70,7 +70,6 @@ public function testDsn(string $dsn, string $file = null) try { $store = new DoctrineDbalStore($dsn); - $store->createTable(); $store->save($key); $this->assertTrue($store->exists($key)); diff --git a/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php index 69968a2f11b80..dd15f0f1614b9 100644 --- a/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php @@ -84,7 +84,6 @@ public function testDsn(string $dsn, string $file = null) try { $store = new PdoStore($dsn); - $store->createTable(); $store->save($key); $this->assertTrue($store->exists($key));