1

This may not be possible at the moment but if anyone had the same problem, how did you handle it?

Is it possible to run the migrations on multiple servers at the same time without running the same scripts multiple times?

The problem I am having is that we are using multiple servers and they run the migrations every time we deploy a new version of our APP. This causes that the same migration scripts are being run several times (depending on how many servers are running it).

Is there a way to check whether the migration is in progress and if yes, skip it or this is something I would need to implement manually?

Many thanks.

pdolinaj
  • 1,087
  • 13
  • 21

2 Answers2

1

This sounds like something you would need to implement manually.

I suggest having a script that executes once when you deploy your app that SSH into one of your servers and executes the migration.

sharif9876
  • 680
  • 6
  • 19
0

I would recommend using Ansible to write a playbook to handle this, while calling all the relevant Hosts (inventories).

The end result would be something like (for example):

If you only wanted to run on a single (or subset list of..):

ansible-playbook --limit YOUR_INVENTORY_NAME run-migrations.yml

Or, for all of them as defined:

ansible-playbook run-migrations.yml

And your actual playbook within Ansible would look something like:

- name: Run Migrations
  command: php bin/console doctrine:migrations:migrate
  args:
    chdir: /path/to/symfony
Jake Litwicki
  • 232
  • 2
  • 5