Skip to content

Execute a subset of migrations based on namespace or tags #1581

@pavlepredic

Description

@pavlepredic

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

Use case

Execute different migrations in different stages. For example, you could have some migrations that are executed before the deployment and others that are executed after the deployment.

Implementation ideas

Allow executing a subset of migrations by passing a parameter to the migrations command. This could be achieved either by specifying a tag or a namespace. Here's how tags could work: you would add a getTags() method to the AbstractMigration, which would return an empty array or null by default. Concrete implementation could override the method and specify arbitrary tags (as an array of strings). When executing the migrations, you could call: ./bin/console doc:mig:mig --tag foo, which would only execute migrations tagged with foo. If you don't specify the --tag parameter, all migrations would be executed (BC is maintained).

Another option would be to specify the namespace of the migrations you wish to execute. This would execute only the migrations in the given namespace. Here's how that could work: ./bin/console doc:mig:mig --namespace MyApp\DoctrineMigrations\PreDeploy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions