Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine Migrations Extra Bundle Laravel Package

sylius-labs/doctrine-migrations-extra-bundle

Symfony bundle extending DoctrineMigrationsBundle with container-aware migration instantiation and topological sorting of migrations across multiple namespaces/bundles. Configure migration dependencies to ensure predictable, correct execution order in apps or bundles.

View on GitHub
Deep Wiki
Context7

Adding a topological sorter and container injection to DoctrineMigrationsBundle.

Installation

  1. Require this package in your project:
composer require sylius-labs/doctrine-migrations-extra-bundle
  1. Add this bundle to config/bundles.php:
return [
    // ...
    SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
];
  1. Replace original Doctrine migrations services with the ones from this bundle by adding the following config in config/packages/doctrine_migrations.yaml:
doctrine_migrations:
    services:
        'Doctrine\Migrations\Version\MigrationFactory': 'SyliusLabs\DoctrineMigrationsExtraBundle\Factory\ContainerAwareVersionFactory'
        'Doctrine\Migrations\Version\Comparator': 'SyliusLabs\DoctrineMigrationsExtraBundle\Comparator\TopologicalVersionComparator'

Usage

In an application

In order to define the topology of migrations, configure it in config/packages/sylius_labs_doctrine_migrations_extra.yaml:

sylius_labs_doctrine_migrations_extra:
    migrations:
        'Core\Migrations': ~
        'PluginDependingOnCommonPlugin\Migrations': ['Core\Migrations', 'CommonPlugin\Migrations']
        'CommonPlugin\Migrations': ['Core\Migrations']
        'PluginDependingOnCore\Migrations': ['Core\Migrations']

The following configuration will result in the following order:

  • Core\Migrations
  • CommonPlugin\Migrations
  • PluginDependingOnCommonPlugin\Migrations
  • PluginDependingOnCore\Migrations

In a bundle

If you want to make your bundle define its dependencies on it own, prepend the configuration in your bundle's extension:

use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;

final class AcmeExtension extends Extension implements PrependExtensionInterface
{
    // ...

    public function prepend(ContainerBuilder $container): void
    {
        if (!$container->hasExtension('doctrine_migrations') || !$container->hasExtension('sylius_labs_doctrine_migrations_extra')) {
            return;
        }

        $container->prependExtensionConfig('doctrine_migrations', [
            'migrations_paths' => [
                'Acme\AcmeBundle\Migrations' => '@AcmeBundle/Migrations',
            ],
        ]);

        $container->prependExtensionConfig('sylius_labs_doctrine_migrations_extra', [
            'migrations' => [
                'Acme\AcmeBundle\Migrations' => ['Core\Migrations'],
            ],
        ]);
    }
}

Generating new diff

Cause this bundle will dynamically change the configuration of Doctrine Migrations, you may need to specify your own namespace like:

# config/packages/doctrine_migrations.yaml
doctrine_migrations:
  migrations_paths:
    'App\Migrations': "%kernel.project_dir%/src/Migrations"

# config/packages/sylius_labs_doctrine_migrations_extra.yaml
sylius_labs_doctrine_migrations_extra:
  migrations:
    'App\Migrations': ~

After that you will be able to generate again your own migration by calling:

bin/console doctrine:migrations:diff --namespace=App\\Migrations

Versioning and release cycle

This package follows semantic versioning.

Next major releases are not planned yet. Minor and patch releases will be published as needed.

Bug fixes will be provided only for the most recent minor release. Security fixes will be provided for one year since the release of subsequent minor release.

License

This extension is completely free and released under permissive MIT license.

Authors

It is originally created by Kamil Kokot. See the list of all contributors.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor