From 0d47ced008b0963ae764dfdecae19ebfa837db30 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 14 Nov 2020 18:55:14 +0100 Subject: [PATCH] Fix oban jobs migrations (especially on PostgreSQL < 12) Signed-off-by: Thomas Citharel --- ..._migrations_for_older_postgre_sql_versions.exs | 15 +++++++++++++++ .../20201114175249_upgrade_oban_jobs_to_v9.exs | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 priv/repo/migrations/20201114174929_fix_oban_migrations_for_older_postgre_sql_versions.exs create mode 100644 priv/repo/migrations/20201114175249_upgrade_oban_jobs_to_v9.exs diff --git a/priv/repo/migrations/20201114174929_fix_oban_migrations_for_older_postgre_sql_versions.exs b/priv/repo/migrations/20201114174929_fix_oban_migrations_for_older_postgre_sql_versions.exs new file mode 100644 index 000000000..3bb2c9d52 --- /dev/null +++ b/priv/repo/migrations/20201114174929_fix_oban_migrations_for_older_postgre_sql_versions.exs @@ -0,0 +1,15 @@ +defmodule Mobilizon.Storage.Repo.Migrations.FixObanMigrationsForOlderPostgreSQLVersions do + use Ecto.Migration + + @disable_ddl_transaction true + def up do + Ecto.Adapters.SQL.query!( + Mobilizon.Storage.Repo, + "ALTER TYPE oban_job_state ADD VALUE IF NOT EXISTS 'cancelled'" + ) + end + + def down do + IO.puts("This migration doesn't handle being reverted.") + end +end diff --git a/priv/repo/migrations/20201114175249_upgrade_oban_jobs_to_v9.exs b/priv/repo/migrations/20201114175249_upgrade_oban_jobs_to_v9.exs new file mode 100644 index 000000000..0c27e83a8 --- /dev/null +++ b/priv/repo/migrations/20201114175249_upgrade_oban_jobs_to_v9.exs @@ -0,0 +1,6 @@ +defmodule Mobilizon.Storage.Repo.Migrations.UpgradeObanJobsToV9 do + use Ecto.Migration + + defdelegate up, to: Oban.Migrations + defdelegate down, to: Oban.Migrations +end