From a6ce2c296443571ffbd971cce0f84af202675235 Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 19 Nov 2018 09:24:13 -0500 Subject: [PATCH] Remove container aware migrations documentation It's not recommended to use services in migrations because they could change or be removed, which could leave your database in an unpredictable state. See #243 for more information. --- Resources/doc/index.rst | 61 ----------------------------------------- 1 file changed, 61 deletions(-) diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 9d56cbd..1a34299 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -329,67 +329,6 @@ If you don't want to use this workflow and instead create your schema via Otherwise Doctrine will try to run all migrations, which probably will not work. -Container Aware Migrations --------------------------- - -In some cases you might need access to the container to ensure the proper update of -your data structure. This could be necessary to update relations with some specific -logic or to create new entities. - -Therefore you can just implement the ContainerAwareInterface with its needed methods -to get full access to the container or ContainerAwareTrait if you use Symfony >= 2.4. - -.. code-block:: php - - // ... - use Symfony\Component\DependencyInjection\ContainerAwareInterface; - use Symfony\Component\DependencyInjection\ContainerInterface; - - class Version20130326212938 extends AbstractMigration implements ContainerAwareInterface - { - private $container; - - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } - - public function up(Schema $schema) - { - // ... migration content - } - - public function postUp(Schema $schema) - { - $converter = $this->container->get('my_service.convert_data_to'); - // ... convert the data from markdown to html for instance - } - } - -With the trait - -.. code-block:: php - - // ... - use Symfony\Component\DependencyInjection\ContainerAwareInterface; - use Symfony\Component\DependencyInjection\ContainerAwareTrait; - - class Version20130326212938 extends AbstractMigration implements ContainerAwareInterface - { - use ContainerAwareTrait; - - public function up(Schema $schema) - { - // ... migration content - } - - public function postUp(Schema $schema) - { - $converter = $this->container->get('my_service.convert_data_to'); - // ... convert the data from markdown to html for instance - } - } - Manual Tables -------------