From 00b33b41b587a876f06617ce9151f4eb9da59877 Mon Sep 17 00:00:00 2001 From: Matthew Rider Date: Mon, 2 Sep 2024 09:45:33 +0200 Subject: [PATCH] Fix migrations in ansible installation playbook (#2006) For some reason, running the schema migrations and data migrations together causing them to fail and requires an addtional step to ssh into every instance and run the data migrations after the schema migrations have run successfully. The data migrations many times rely on the schema being migrated, but it was my understanding that the db:migrate:with_data accounted for this. In practice, however, it reliably fails every time. --- ansible/roles/installation/tasks/main.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ansible/roles/installation/tasks/main.yml b/ansible/roles/installation/tasks/main.yml index a4ced58fb..1bdca7f43 100644 --- a/ansible/roles/installation/tasks/main.yml +++ b/ansible/roles/installation/tasks/main.yml @@ -73,7 +73,12 @@ community.docker.docker_prune: images: yes -- name: Create and migrate database +- name: Run schema migrations command: - cmd: docker compose -f docker-compose.yml -f docker-compose.prod.yml exec app bin/rails db:migrate:with_data + cmd: docker compose -f docker-compose.yml -f docker-compose.prod.yml exec app bin/rails db:migrate + chdir: /home/ansible + +- name: Run data migrations + command: + cmd: docker compose -f docker-compose.yml -f docker-compose.prod.yml exec app bin/rails data:migrate chdir: /home/ansible