You are browsing a version that is no longer maintained.

Custom Configuration

It is possible to build a custom configuration where you manually build the Doctrine\Migrations\Configuration\Configuration instance instead of using YAML, XML, etc. In order to do this, you will need to setup a Custom Integration.

Once you have your custom integration setup, you can modify it to look like the following:

1#!/usr/bin/env php <?php require_once __DIR__.'/vendor/autoload.php'; use Doctrine\DBAL\DriverManager; use Doctrine\Migrations\Configuration\Configuration; use Doctrine\Migrations\Configuration\Connection\ExistingConnection; use Doctrine\Migrations\Configuration\Configuration\ExistingConfiguration; use Doctrine\Migrations\DependencyFactory; use Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration; use Doctrine\Migrations\Tools\Console\Command; use Symfony\Component\Console\Application; $dbParams = [ 'dbname' => 'migrations_docs_example', 'user' => 'root', 'password' => '', 'host' => 'localhost', 'driver' => 'pdo_mysql', ]; $connection = DriverManager::getConnection($dbParams); $configuration = new Configuration($connection); $configuration->setName('My Project Migrations'); $configuration->addMigrationsDirectory('MyProject\Migrations', '/data/doctrine/migrations-docs-example/lib/MyProject/Migrations'); $configuration->setAllOrNothing(true); $configuration->setCheckDatabasePlatform(false); $storageConfiguration = new TableMetadataStorageConfiguration(); $storageConfiguration->setTableName('doctrine_migration_versions'); $configuration->setMetadataStorageConfiguration($storageConfiguration); $dependencyFactory = DependencyFactory::fromConnection( new ExistingConfiguration($configuration), new ExistingConnection($connection) ); $cli = new Application('Doctrine Migrations'); $cli->setCatchExceptions(true); $cli->addCommands(array( new Command\DumpSchemaCommand($dependencyFactory), new Command\ExecuteCommand($dependencyFactory), new Command\GenerateCommand($dependencyFactory), new Command\LatestCommand($dependencyFactory), new Command\ListCommand($dependencyFactory), new Command\MigrateCommand($dependencyFactory), new Command\RollupCommand($dependencyFactory), new Command\StatusCommand($dependencyFactory), new Command\SyncMetadataCommand($dependencyFactory), new Command\VersionCommand($dependencyFactory), )); $cli->run();
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

Next Chapter: Migrations Events