Skip to content

Commit f7ec29d

Browse files
committed
Add migration template
1 parent e00142d commit f7ec29d

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

config/doctrine_migrations.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ doctrine_migrations:
44
# 'TatevikGr\RssBundle\RssFeedBundle\Migrations': '%kernel.project_dir%/vendor/tatevikgr/rss-bundle/src/RssFeedBundle/Migrations'
55
all_or_nothing: true
66
organize_migrations: false
7+
custom_template: '%kernel.project_dir%/src/Migrations/_template_migration.php'
78
storage:
89
table_storage:
910
table_name: 'doctrine_migration_versions'
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace <namespace>;
6+
7+
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
8+
use Doctrine\DBAL\Platforms\MySQLPlatform;
9+
use Doctrine\Migrations\AbstractMigration;
10+
use Doctrine\DBAL\Schema\Schema;
11+
12+
final class <className> extends AbstractMigration
13+
{
14+
public function getDescription(): string
15+
{
16+
return '<comment>';
17+
}
18+
19+
public function up(Schema $schema): void
20+
{
21+
$platform = $this->connection->getDatabasePlatform();
22+
$this->skipIf(!$platform instanceof <platform>, sprintf(
23+
'Unsupported platform for this migration: %s',
24+
get_class($platform)
25+
));
26+
27+
<up>
28+
}
29+
30+
public function down(Schema $schema): void
31+
{
32+
$platform = $this->connection->getDatabasePlatform();
33+
$this->skipIf(!$platform instanceof <platform>, sprintf(
34+
'Unsupported platform for this migration: %s',
35+
get_class($platform)
36+
));
37+
38+
<down>
39+
}
40+
}

0 commit comments

Comments
 (0)