Quantcast
Channel: Symfony Blog
Viewing all articles
Browse latest Browse all 3057

New in Symfony 5.1: Automatic schema updates

$
0
0
Ryan Weaver

Contributed by
Ryan Weaver
in #36655.

Some Symfony components (e.g. Cache, Lock, Messenger, etc.) can store their contents in databases using Doctrine ORM. This requires some manual setup to work. For example, to store sessions in the database you must create the table that stores the information.

We're big fans of automation, so we decided to automate all this in Symfony 5.1. The idea is to implement some event subscribers that listen to advanced Doctrine events (e.g. Events::onSchemaCreateTable from Doctrine DBAL andToolEvents::postGenerateSchema from Doctrine ORM) and inject the SQL code required to create the database tables needed by each component.

These automatic database tables are generated only when you really need them. Consider for example the Messenger component. If you configure a Doctrine transport and run the make:migration command, the database is created. Otherwise, nothing will change in your database. The same happens when usingPdoAdapter from Cache component, PdoStore from Lock component, etc.

Symfony Docs will be updated soon to reflect this automation and simplify the setup required in some components.


Sponsor the Symfony project.

Viewing all articles
Browse latest Browse all 3057

Trending Articles