Skip to content

How to prevent doctrine:migrations:diff modify a column? #10260

Discussion options

You must be logged in to vote

Okay, no one seems to know :)
I found a temporary solution with deprecated events, which should be enough if events not removed before DBAL 4 is released.

<?php
declare(strict_types=1);

namespace App\Event\Listener\Doctrine;

use Doctrine\Common\EventSubscriber;
use Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs;
use Doctrine\DBAL\Events;

final class BeforeDBAL4EventListener implements EventSubscriber
{
    public function onSchemaAlterTableChangeColumn(SchemaAlterTableChangeColumnEventArgs $args)
    {
        if ($args->getColumnDiff()->hasAutoIncrementChanged()) {
            switch ($args->getTableDiff()->getOldTable()->getName()) {
                case 'table1':
        …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by berkut1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant