Skip to content

Change the way to create table in Lock PDO #14130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions components/lock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,25 +350,11 @@ support blocking, and expects a TTL to avoid stalled locks::

This store does not support TTL lower than 1 second.

Before storing locks in the database, you must create the table that stores
the information. The store provides a method called
:method:`Symfony\\Component\\Lock\\Store\\PdoStore::createTable`
to set up this table for you according to the database engine used::

try {
$store->createTable();
} catch (\PDOException $exception) {
// the table could not be created for some reason
}

A great way to set up the table in production is to call the ``createTable()``
method in your local computer and then generate a
:ref:`database migration <doctrine-creating-the-database-tables-schema>`:

.. code-block:: terminal

$ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrate
The table where values are stored is created automatically on the first call to
the :method:`Symfony\\Component\\Lock\\Store\\PdoStore::save` method.
You can also create this table explicitly by calling the
:method:`Symfony\\Component\\Lock\\Store\\PdoStore::createTable` method in
your code.

.. _lock-store-redis:

Expand Down