From 370e5051cb168cff056e11513aa0e29c095e855d Mon Sep 17 00:00:00 2001 From: Simonas Kareiva Date: Tue, 15 Sep 2026 21:34:43 +0300 Subject: [PATCH] Run migrations if the container changed --- roles/mastodon/handlers/main.yml | 6 ++++++ roles/mastodon/tasks/sidekiq.yml | 4 +++- roles/mastodon/tasks/web.yml | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/roles/mastodon/handlers/main.yml b/roles/mastodon/handlers/main.yml index 020e0bc..9c3dca3 100644 --- a/roles/mastodon/handlers/main.yml +++ b/roles/mastodon/handlers/main.yml @@ -6,3 +6,9 @@ ansible.builtin.systemd_service: daemon_reload: true scope: user + +- name: Run mastodon database migrations + ansible.builtin.command: + cmd: podman exec mastodon rails db:migrate + register: mastodon_db_migrate + changed_when: mastodon_db_migrate.stdout | length > 0 diff --git a/roles/mastodon/tasks/sidekiq.yml b/roles/mastodon/tasks/sidekiq.yml index af072e4..cecc30c 100644 --- a/roles/mastodon/tasks/sidekiq.yml +++ b/roles/mastodon/tasks/sidekiq.yml @@ -10,4 +10,6 @@ state: present src: "{{ mastodon_quadlet_tmp.path }}/sidekiq.container" reload_systemd: false - notify: Reload systemd user units + notify: + - Reload systemd user units + - Run mastodon database migrations diff --git a/roles/mastodon/tasks/web.yml b/roles/mastodon/tasks/web.yml index c408511..0aa8efe 100644 --- a/roles/mastodon/tasks/web.yml +++ b/roles/mastodon/tasks/web.yml @@ -10,4 +10,6 @@ state: present src: "{{ mastodon_quadlet_tmp.path }}/mastodon.container" reload_systemd: false - notify: Reload systemd user units + notify: + - Reload systemd user units + - Run mastodon database migrations