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.
This commit is contained in:
parent
95c009db0d
commit
bd265564a2
1 changed files with 14 additions and 2 deletions
|
|
@ -1,7 +1,19 @@
|
|||
defmodule Aprsme.Repo.Migrations.EnablePgStatStatements do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
execute "CREATE EXTENSION IF NOT EXISTS pg_stat_statements"
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue