Skip to content

Commit

Permalink
Merge pull request #1128 from Holicz/3.1.x
Browse files Browse the repository at this point in the history
Add Custom migration template into the documentation
  • Loading branch information
greg0ire authored Feb 22, 2021
2 parents 260991b + 7151551 commit 9112d14
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions docs/en/reference/custom-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?php
declare(strict_types=1);
namespace <namespace>;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class <className> extends AbstractMigration
{
public function up(Schema $schema): void
{
<up>
}
}
Placeholders (words inside ``< >``) are replaced with correct code upon generation. All possible wildcards are:

=============== ===============================================
Placeholder Description
--------------- -----------------------------------------------
``<namespace>`` Namespace of the class, e.g. ``App\Migrations``
``<className>`` Classname, e.g. ``Version20210212092730``
``<up>`` SQL for migrating up
``<down>`` SQL for migrating down
=============== ===============================================

The custom template needs to be configured.

.. code-block:: php
$configuration->setCustomTemplate(__DIR__ . '/custom_template.tpl');

0 comments on commit 9112d14

Please sign in to comment.