maximaster/doctrine-migration-comparators

Comparator to sort migrations by their namespace in the order of regex-match list.

v1.0.0 2024-08-30 11:57 UTC

This package is auto-updated.

Last update: 2024-10-30 13:56:36 UTC


README

composer require maximaster/doctrine-migration-comparators

NumericComparator

Compares numeric parts of versons as numbers.

MatchComparator

Comparator that prioritize versions which matches first on list of regexps.

You can use other comparator as fallback in case migrations have the same regexp matched. For example: the library's NumericComparator or softspring/doctrine-migrations-version-comparator

Example

config/packages/doctrine_migrations.yaml

doctrine_migrations:
    services:
        Doctrine\Migrations\Version\Comparator: Maximaster\DoctrineMigrationComparators\Comparator\MatchComparator

services.yaml

    Maximaster\DoctrineMigrationComparators\Comparator\MatchComparator:
        arguments:
            -
                - ~MyProject\Process~
                - ~MyProject\Tests~
            - '@Maximaster\DoctrineMigrationComparators\Comparator\NumericComparator'

MyProject\Process migrations would be executed first, then MyProject\Tests.