diff --git a/.github/workflows/composer-lint.yml b/.github/workflows/composer-lint.yml
new file mode 100644
index 0000000..638a141
--- /dev/null
+++ b/.github/workflows/composer-lint.yml
@@ -0,0 +1,20 @@
+name: "Composer Lint"
+
+on:
+ pull_request:
+ branches:
+ - "*.x"
+ paths:
+ - ".github/workflows/composer-lint.yml"
+ - "composer.json"
+ push:
+ branches:
+ - "*.x"
+ paths:
+ - ".github/workflows/composer-lint.yml"
+ - "composer.json"
+
+jobs:
+ composer-lint:
+ name: "Composer Lint"
+ uses: "doctrine/.github/.github/workflows/composer-lint.yml@7.1.0"
diff --git a/composer.json b/composer.json
index fbafe82..80ee7bc 100644
--- a/composer.json
+++ b/composer.json
@@ -1,10 +1,13 @@
{
"name": "doctrine/doctrine-migrations-bundle",
- "type": "symfony-bundle",
"description": "Symfony DoctrineMigrationsBundle",
- "keywords": ["DBAL", "Migrations", "Schema"],
- "homepage": "https://www.doctrine-project.org",
"license": "MIT",
+ "type": "symfony-bundle",
+ "keywords": [
+ "DBAL",
+ "Migrations",
+ "Schema"
+ ],
"authors": [
{
"name": "Fabien Potencier",
@@ -19,31 +22,36 @@
"homepage": "https://symfony.com/contributors"
}
],
+ "homepage": "https://www.doctrine-project.org",
"require": {
"php": "^8.1",
- "symfony/deprecation-contracts": "^2.1 || ^3",
- "symfony/framework-bundle": "^6.4 || ^7.0",
"doctrine/doctrine-bundle": "^2.8",
- "doctrine/migrations": "^3.2"
+ "doctrine/migrations": "^3.2",
+ "symfony/deprecation-contracts": "^2.1 || ^3",
+ "symfony/framework-bundle": "^6.4 || ^7.0"
},
"require-dev": {
"composer/semver": "^3.0",
"phpunit/phpunit": "^10.5.40 || ^11.5",
"doctrine/coding-standard": "^12",
+ "doctrine/orm": "^2.15 || ^3",
+ "doctrine/persistence": "^3.1 ",
"phpstan/phpstan": "^2",
"phpstan/phpstan-deprecation-rules": "^2",
"phpstan/phpstan-phpunit": "^2",
"phpstan/phpstan-strict-rules": "^2",
"phpstan/phpstan-symfony": "^2",
- "doctrine/orm": "^2.15 || ^3",
- "doctrine/persistence": "^3.1 ",
"symfony/var-exporter": "^6.4 || ^7"
},
"autoload": {
- "psr-4": { "Doctrine\\Bundle\\MigrationsBundle\\": "src" }
+ "psr-4": {
+ "Doctrine\\Bundle\\MigrationsBundle\\": "src"
+ }
},
"autoload-dev": {
- "psr-4": { "Doctrine\\Bundle\\MigrationsBundle\\Tests\\": "tests" }
+ "psr-4": {
+ "Doctrine\\Bundle\\MigrationsBundle\\Tests\\": "tests"
+ }
},
"config": {
"allow-plugins": {
diff --git a/config/services.xml b/config/services.xml
index da9b6ee..3f99173 100644
--- a/config/services.xml
+++ b/config/services.xml
@@ -138,6 +138,11 @@
+
+
+
+
+
diff --git a/src/DependencyInjection/DoctrineMigrationsExtension.php b/src/DependencyInjection/DoctrineMigrationsExtension.php
index 51e75a6..48d6a3a 100644
--- a/src/DependencyInjection/DoctrineMigrationsExtension.php
+++ b/src/DependencyInjection/DoctrineMigrationsExtension.php
@@ -88,15 +88,21 @@ public function load(array $configs, ContainerBuilder $container): void
$diDefinition->addMethodCall('setDefinition', [$doctrineId, new Reference($symfonyId)]);
}
- if (! isset($config['services'][MetadataStorage::class])) {
+ if (isset($config['services'][MetadataStorage::class])) {
+ $container->removeDefinition('doctrine_migrations.schema_filter_listener');
+ } else {
+ $filterDefinition = $container->getDefinition('doctrine_migrations.schema_filter_listener');
$storageConfiguration = $config['storage']['table_storage'];
$storageDefinition = new Definition(TableMetadataStorageConfiguration::class);
$container->setDefinition('doctrine.migrations.storage.table_storage', $storageDefinition);
$container->setAlias('doctrine.migrations.metadata_storage', 'doctrine.migrations.storage.table_storage');
- if ($storageConfiguration['table_name'] !== null) {
+ if ($storageConfiguration['table_name'] === null) {
+ $filterDefinition->addArgument('doctrine_migration_versions');
+ } else {
$storageDefinition->addMethodCall('setTableName', [$storageConfiguration['table_name']]);
+ $filterDefinition->addArgument($storageConfiguration['table_name']);
}
if ($storageConfiguration['version_column_name'] !== null) {
diff --git a/src/EventListener/SchemaFilterListener.php b/src/EventListener/SchemaFilterListener.php
new file mode 100644
index 0000000..203739b
--- /dev/null
+++ b/src/EventListener/SchemaFilterListener.php
@@ -0,0 +1,58 @@
+configurationTableName = $configurationTableName;
+ }
+
+ /** @var bool */
+ private $enabled = true;
+
+ /** @param AbstractAsset|string $asset */
+ public function __invoke($asset): bool
+ {
+ if (! $this->enabled) {
+ return true;
+ }
+
+ if ($asset instanceof AbstractAsset) {
+ $asset = $asset->getName();
+ }
+
+ return $asset !== $this->configurationTableName;
+ }
+
+ private function disable(): void
+ {
+ $this->enabled = false;
+ }
+
+ public function onConsoleCommand(ConsoleCommandEvent $event): void
+ {
+ $command = $event->getCommand();
+
+ if (! $command instanceof DoctrineCommand) {
+ return;
+ }
+
+ $this->disable();
+ }
+}
diff --git a/tests/Collector/EventListener/SchemaFilterListenerTest.php b/tests/Collector/EventListener/SchemaFilterListenerTest.php
new file mode 100644
index 0000000..2d2e0a1
--- /dev/null
+++ b/tests/Collector/EventListener/SchemaFilterListenerTest.php
@@ -0,0 +1,39 @@
+onConsoleCommand(new ConsoleCommandEvent(
+ $migrationsCommand,
+ new ArrayInput([]),
+ new NullOutput()
+ ));
+
+ self::assertTrue($listener(new Table('doctrine_migration_versions')));
+ }
+}