|
8 | 8 | use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
9 | 9 | use Symfony\Component\Config\Definition\ConfigurationInterface;
|
10 | 10 | use function constant;
|
| 11 | +use function count; |
11 | 12 | use function in_array;
|
12 | 13 | use function is_string;
|
13 | 14 | use function method_exists;
|
@@ -41,14 +42,75 @@ public function getConfigTreeBuilder() : TreeBuilder
|
41 | 42 |
|
42 | 43 | $rootNode
|
43 | 44 | ->children()
|
44 |
| - ->scalarNode('dir_name')->defaultValue('%kernel.root_dir%/DoctrineMigrations')->cannotBeEmpty()->end() |
45 |
| - ->scalarNode('namespace')->defaultValue('Application\Migrations')->cannotBeEmpty()->end() |
46 |
| - ->scalarNode('table_name')->defaultValue('migration_versions')->cannotBeEmpty()->end() |
47 |
| - ->scalarNode('column_name')->defaultValue('version')->end() |
48 |
| - ->scalarNode('column_length')->defaultValue(14)->end() |
49 |
| - ->scalarNode('executed_at_column_name')->defaultValue('executed_at')->end() |
50 |
| - ->scalarNode('all_or_nothing')->defaultValue(false)->end() |
51 | 45 | ->scalarNode('name')->defaultValue('Application Migrations')->end()
|
| 46 | + |
| 47 | + // 3.x forward compatibility layer |
| 48 | + ->arrayNode('migrations_paths') |
| 49 | + ->info('A list of pairs namespace/path where to look for migrations.') |
| 50 | + ->useAttributeAsKey('name') |
| 51 | + ->defaultValue([]) |
| 52 | + ->prototype('scalar')->end() |
| 53 | + ->validate() |
| 54 | + ->ifTrue(static function ($v) { |
| 55 | + return count($v) === 0; |
| 56 | + }) |
| 57 | + ->thenInvalid('At least one migrations path must be specified.') |
| 58 | + |
| 59 | + ->ifTrue(static function ($v) { |
| 60 | + return count($v) > 1; |
| 61 | + }) |
| 62 | + ->thenInvalid('Maximum one migration path can be specified with the 2.x version.') |
| 63 | + ->end() |
| 64 | + ->end() |
| 65 | + |
| 66 | + ->arrayNode('storage') |
| 67 | + ->info('Storage to use for migration status metadata.') |
| 68 | + ->children() |
| 69 | + ->arrayNode('table_storage') |
| 70 | + ->info('The default metadata storage, implemented as table in the database.') |
| 71 | + ->children() |
| 72 | + ->scalarNode('table_name')->defaultValue(null)->cannotBeEmpty()->end() |
| 73 | + ->scalarNode('version_column_name')->defaultValue(null)->end() |
| 74 | + ->scalarNode('version_column_length') |
| 75 | + ->defaultValue(null) |
| 76 | + ->validate() |
| 77 | + ->ifTrue(static function ($v) { |
| 78 | + return $v< 1024; |
| 79 | + }) |
| 80 | + ->thenInvalid('The minimum length for the version column is 1024.') |
| 81 | + ->end() |
| 82 | + ->end() |
| 83 | + ->scalarNode('executed_at_column_name')->defaultValue(null)->end() |
| 84 | + ->end() |
| 85 | + ->end() |
| 86 | + ->end() |
| 87 | + ->end() |
| 88 | + |
| 89 | + ->scalarNode('dir_name') |
| 90 | + ->defaultValue('%kernel.root_dir%/DoctrineMigrations')->cannotBeEmpty() |
| 91 | + ->setDeprecated('The "%node%" option is deprecated. Use "migrations_paths" instead.') |
| 92 | + ->end() |
| 93 | + ->scalarNode('namespace') |
| 94 | + ->defaultValue('Application\Migrations')->cannotBeEmpty() |
| 95 | + ->setDeprecated('The "%node%" option is deprecated. Use "migrations_paths" instead.') |
| 96 | + ->end() |
| 97 | + ->scalarNode('table_name') |
| 98 | + ->defaultValue('migration_versions')->cannotBeEmpty() |
| 99 | + ->setDeprecated('The "%node%" option is deprecated. Use "storage.table_storage.table_name" instead.') |
| 100 | + ->end() |
| 101 | + ->scalarNode('column_name') |
| 102 | + ->defaultValue('version') |
| 103 | + ->setDeprecated('The "%node%" option is deprecated. Use "storage.table_storage.version_column_name" instead.') |
| 104 | + ->end() |
| 105 | + ->scalarNode('column_length') |
| 106 | + ->defaultValue(14) |
| 107 | + ->setDeprecated('The "%node%" option is deprecated. Use "storage.table_storage.version_column_length" instead.') |
| 108 | + ->end() |
| 109 | + ->scalarNode('executed_at_column_name') |
| 110 | + ->defaultValue('executed_at') |
| 111 | + ->setDeprecated('The "%node%" option is deprecated. Use "storage.table_storage.executed_at_column_name" instead.') |
| 112 | + ->end() |
| 113 | + ->scalarNode('all_or_nothing')->defaultValue(false)->end() |
52 | 114 | ->scalarNode('custom_template')->defaultValue(null)->end()
|
53 | 115 | ->scalarNode('organize_migrations')->defaultValue(false)
|
54 | 116 | ->info('Organize migrations mode. Possible values are: "BY_YEAR", "BY_YEAR_AND_MONTH", false')
|
|
0 commit comments