Skip to content

Instantly share code, notes, and snippets.

@KaiCMueller
Last active November 28, 2023 07:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save KaiCMueller/c4f65206d541f0fca1fad89600b384ea to your computer and use it in GitHub Desktop.
Save KaiCMueller/c4f65206d541f0fca1fad89600b384ea to your computer and use it in GitHub Desktop.
Doctrine Migrations Template
doctrine_migrations:
dir_name: "%kernel.project_dir%/src/Migrations"
namespace: "App\\Migrations"
custom_template: "%kernel.project_dir%/src/Migrations/migration.tpl"
<?php declare(strict_types = 1);
namespace <namespace>;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version<version> extends AbstractMigration
{
/**
* @param \Doctrine\DBAL\Schema\Schema $schema
*
* @return void
*/
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
<up>
}
/**
* @param \Doctrine\DBAL\Schema\Schema $schema
*
* @return void
*/
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
<down>
}
}
@KaiCMueller
Copy link
Author

KaiCMueller commented Jun 28, 2018

This is an example on how to create a custom template file for doctrine migrations.
"doctrine_migrations.yaml" is a symfony configuration file with the path pointing to the template file.

https://medium.com/@kcmueller/create-a-custom-template-for-doctrine-migrations-24d2b0314376

@dlancea
Copy link

dlancea commented Jun 21, 2021

As of Doctrine Migrations 3.1 <version> is no longer used. Now the whole class name is set with <className>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment