From 7151551cb7a6f0ef13b9696d83a8182885602fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=CC=81s=CC=8C=20Holeczy?= Date: Fri, 19 Feb 2021 16:19:40 +0100 Subject: [PATCH] Add Custom migration template into the documentation --- docs/en/reference/custom-configuration.rst | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/docs/en/reference/custom-configuration.rst b/docs/en/reference/custom-configuration.rst index 859e7fde14..f3be9a8e34 100644 --- a/docs/en/reference/custom-configuration.rst +++ b/docs/en/reference/custom-configuration.rst @@ -127,3 +127,47 @@ With this configuration you can use the ``--conn`` parameter to specify a connec migrations. If the parameter is not passed, it will fallback to the one passed in the configuration, and if that is also not provided it will fallback to the default connection name specified when creating the connection registry. + +Custom migration template +------------------------- + +When the default generated migrations do not suit your needs, you may provide a custom migration template that will +be used to generate future migrations. + +For example, if you don't need a ``down`` migration your template could look like this: + +.. code-block:: php + + ; + + use Doctrine\DBAL\Schema\Schema; + use Doctrine\Migrations\AbstractMigration; + + final class extends AbstractMigration + { + public function up(Schema $schema): void + { + + } + } + +Placeholders (words inside ``< >``) are replaced with correct code upon generation. All possible wildcards are: + +=============== =============================================== +Placeholder Description +--------------- ----------------------------------------------- +```` Namespace of the class, e.g. ``App\Migrations`` +```` Classname, e.g. ``Version20210212092730`` +```` SQL for migrating up +```` SQL for migrating down +=============== =============================================== + +The custom template needs to be configured. + +.. code-block:: php + + $configuration->setCustomTemplate(__DIR__ . '/custom_template.tpl');