Skip to content

Commit

Permalink
Multiple migration directories
Browse files Browse the repository at this point in the history
  • Loading branch information
chuchy4ever authored and f3l1x committed Jul 22, 2024
1 parent 2cc81a0 commit 2821ca6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ extensions:
nettrine.migrations:
table: <string>
column: <string>
directory: <path>
namespace: <string>
directories: <array>
versionsOrganization: <null|year|year_and_month>
customTemplate: <null|path>
```
Expand All @@ -82,7 +81,8 @@ Minimal configuration:

```yaml
nettrine.migrations:
directory: %appDir%/migrations
directories:
App\Migrations: %appDir%/migrations
```


Expand Down
8 changes: 5 additions & 3 deletions src/DI/MigrationsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public function getConfigSchema(): Schema
return Expect::structure([
'table' => Expect::string('doctrine_migrations'),
'column' => Expect::string('version'),
'directory' => Expect::string()->required(),
'namespace' => Expect::string('Migrations'),
'directories' => Expect::array()->required(),
'versionsOrganization' => Expect::anyOf(
null,
Configuration::VERSIONS_ORGANIZATION_BY_YEAR,
Expand Down Expand Up @@ -63,9 +62,12 @@ public function loadConfiguration(): void
->setFactory(Configuration::class)
->addSetup('setCustomTemplate', [$config->customTemplate])
->addSetup('setMetadataStorageConfiguration', [$storage])
->addSetup('addMigrationsDirectory', [$config->namespace, $config->directory])
->addSetup('setAllOrNothing', [$config->allOrNothing]);

foreach ($config->directories as $namespace => $directory) {
$configuration->addSetup('addMigrationsDirectory', [$namespace, $directory]);
}

if ($config->versionsOrganization === Configuration::VERSIONS_ORGANIZATION_BY_YEAR) {
$configuration->addSetup('setMigrationsAreOrganizedByYear');
} elseif ($config->versionsOrganization === Configuration::VERSIONS_ORGANIZATION_BY_YEAR_AND_MONTH) {
Expand Down

0 comments on commit 2821ca6

Please sign in to comment.