aprs.me/priv/repo/migrations/20250707214530_enable_pg_stat_statements.exs
Graham McIntire bd265564a2
Handle insufficient privileges in pg_stat_statements migration
Wrap CREATE EXTENSION in a PL/pgSQL DO block that catches
insufficient_privilege so the migration completes successfully
even when the DB user is not a superuser.
2026-02-18 12:09:56 -06:00

19 lines
442 B
Elixir

defmodule Aprsme.Repo.Migrations.EnablePgStatStatements do
use Ecto.Migration
def up do
execute """
DO $$
BEGIN
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
EXCEPTION WHEN insufficient_privilege THEN
RAISE NOTICE 'Skipping pg_stat_statements: insufficient privileges (requires superuser)';
END;
$$
"""
end
def down do
execute "DROP EXTENSION IF EXISTS pg_stat_statements"
end
end