2

I have an entity with field $usedMB. I'm using Doctrine2 as ORM and DoctrineMigrationsBundle for DB migrations.

/**
 * @ORM\Entity
 */
class DeviceStatus
{
    ...

    /**
     * @ORM\Column(type="float", nullable=true, options={"unsigned":true})
     */
    private $usedMB;

    ...
}

If I execute command php bin/console doctrine:migrations:diff, I get the following line in the migrations file: ALTER TABLE device_status CHANGE used_mb used_mb DOUBLE PRECISION DEFAULT NULL After that, I execute command php bin/console doctrine:migrations:migrate, and I get the message that migration executed successfully.

But the problem is - if I execute php bin/console doctrine:migrations:diff again, I get the same line in the migrations file: ALTER TABLE device_status CHANGE used_mb used_mb DOUBLE PRECISION DEFAULT NULL Just to point out - no code changes were made between executing commands.

After that, I execute command php bin/console doctrine:migrations:migrate, and again - I get the message that migration executed successfully. And that could go on forever.

This is how concrete field in DB looks: db field

Can some please explain me why is the same migration generated every time?

Matko Đipalo
  • 1,676
  • 1
  • 11
  • 23
  • 1
    Does `doctrine:schema:update --dump` returns the same query? – Jakub Matczak Jun 28 '17 at 10:27
  • Yes, it is. It gives the exact same result. – Matko Đipalo Jun 28 '17 at 10:53
  • Try to `clear:cache --env=dev` – Jakub Matczak Jun 28 '17 at 10:57
  • After cache cleanup I get the same result :/ – Matko Đipalo Jun 28 '17 at 10:59
  • 1
    The problem is the "unsigned" option. If you look at the generated SQL it is missing. According to the Docs the annotation usage looks fine. I can reproduce this behaviour. Even trying to manually set the unsigned property in the DB after adding the Column doesn't help. Could possibly be a doctrine bug itself. Removing the unsigned option and it's working fine. – Joe Jun 28 '17 at 11:04
  • 2
    Yeah definitely doctrine bug, even found the open bug report: https://github.com/doctrine/dbal/issues/2380 to be fixed in doctrine 2.6 which is not yet released – Joe Jun 28 '17 at 11:07
  • Yeah. If I remove unsigned option, everything works. Thank you. Could you please c/p your comments, and create an answer, so I can accept it. Maybe it would be helpful to some other people :) – Matko Đipalo Jun 28 '17 at 11:09

1 Answers1

2

The problem is a bug handling the "unsigned" option with doctrine itself.

Currently theres an open bug report for this topic in the respository: https://github.com/doctrine/dbal/issues/2380

The fix should be released with v2.6

Joe
  • 2,356
  • 10
  • 15