mobilizon/priv/repo/migrations/20220506105150_remove_refresh_instance_triggers.exs
Thomas Citharel 6a937d6ede
Remove refresh instance triggers
There are not needed anymore, instances are always refreshed when adding
a new one, and we refresh periodically

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2022-05-06 12:52:39 +02:00

34 lines
758 B
Elixir

defmodule Mobilizon.Storage.Repo.Migrations.RemoveRefreshInstanceTriggers do
use Ecto.Migration
def up do
execute("""
DROP TRIGGER IF EXISTS refresh_instances_trigger_new ON actors;
""")
execute("""
DROP TRIGGER IF EXISTS refresh_instances_trigger_old ON actors;
""")
end
def down do
execute("""
CREATE TRIGGER refresh_instances_trigger_new
AFTER INSERT OR UPDATE
ON actors
FOR EACH ROW
WHEN (NEW.preferred_username = 'relay')
EXECUTE PROCEDURE refresh_instances();
""")
execute("""
CREATE TRIGGER refresh_instances_trigger_old
AFTER DELETE
ON actors
FOR EACH ROW
WHEN (OLD.preferred_username = 'relay')
EXECUTE PROCEDURE refresh_instances();
""")
end
end