3

I know that It seems a strange behaviour avoid exceptions in doctrine but I need to do that because I am working in a old project and someone in the past executed some migrations and then he decided remove it so right now is complicated to replicate production enviroment in local without crashes, and this is the reason why I need to executed some query (Remove foreign key and add againg to be sure that I have the same enviroment in local as in production.

It is possible to do that? Of course I tried with try/catch but is not working, I read doctrine documentation but there is not information about, so it seems that is not possible but maybe there are a approach to do that

Castor Duran
  • 309
  • 1
  • 16

1 Answers1

3

I was not able to catch exceptions, so to solve I decided to create two differents migrations file, the first one for development and the second one for production. To execute only in the correct environment I call to the skipIf and I only execute this query if I am not in production.

$this->skipIf('prod' === getenv('SYMFONY_ENV'), "This migrations is only executed in develop and test enviroments");

I know that is not the best approach but is the good one in order to this problem.

Castor Duran
  • 309
  • 1
  • 16