02:41:20.869 [info] == Running Pleroma.Repo.Migrations.UpdateActivityVisibility.up/0 forward
02:41:20.869 [info] execute "create or replace function activity_visibility(actor varchar, recipients varchar[], data jsonb) returns varchar as $$\nDECLARE\n  fa varchar;\n  public varchar := 'https://www.w3.org/ns/activitystreams#Public';\nBEGIN\n  SELECT COALESCE(users.follower_address, '') into fa from users where users.ap_id = actor;\n\n  IF data->'to' ? public THEN\n    RETURN 'public';\n  ELSIF data->'cc' ? public THEN\n    RETURN 'unlisted';\n  ELSIF ARRAY[fa] && recipients THEN\n    RETURN 'private';\n  ELSIF not(ARRAY[fa, public] && recipients) THEN\n    RETURN 'direct';\n  ELSE\n    RETURN 'unknown';\n  END IF;\nEND;\n$$ LANGUAGE plpgsql IMMUTABLE PARALLEL SAFE SECURITY DEFINER;\n"
** (Postgrex.Error) ERROR 42601 (syntax_error): syntax error at or near "PARALLEL"
    (ecto) lib/ecto/adapters/sql.ex:200: Ecto.Adapters.SQL.query!/5
    (ecto) lib/ecto/adapters/postgres.ex:96: anonymous fn/4 in Ecto.Adapters.Postgres.execute_ddl/3
    (elixir) lib/enum.ex:1940: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/adapters/postgres.ex:96: Ecto.Adapters.Postgres.execute_ddl/3
    (ecto) lib/ecto/migration/runner.ex:104: anonymous fn/2 in Ecto.Migration.Runner.flush/0
    (elixir) lib/enum.ex:1940: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/migration/runner.ex:102: Ecto.Migration.Runner.flush/0
    (stdlib) timer.erl:181: :timer.tc/2


This is what happens when you try to do the Pleroma FlakeID migration using Postgres 9.5.

Updating from Ubuntu 16.04 to 18.04 went smoothly, as did migrating the database to Postgres 10. After that, the FlakeID migration was possible because Postgres 10 supports the “PARALLEL” instruction which caused the error in Postgres 9.5 visible above.