PG::InvalidParameterValue: ERROR: invalid value for parameter “client_min_messages”: “panic”

前端 未结 6 815
無奈伤痛
無奈伤痛 2020-12-18 19:13

rake db:create showing error PG::InvalidParameterValue: ERROR: invalid value for parameter \"client_min_messages\": \"panic\" HINT: Available values: debug5, debug4, debug

相关标签:
6条回答
  • 2020-12-18 19:27

    To make it work with PostgreSQL version 12, I monkey patched PostgreSQLAdapter class to replace 'panic' with 'warning' message. Note, if you can upgrade activerecord gem to 4.2.6 or higher versions you don't need to have this monkey patch. I had to do this because my project depends on gem activerecord-3.2.22.5

    require 'active_record/connection_adapters/postgresql_adapter'
    
    class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
      def set_standard_conforming_strings
        old, self.client_min_messages = client_min_messages, 'warning'
        execute('SET standard_conforming_strings = on', 'SCHEMA') rescue nil
      ensure
        self.client_min_messages = old
      end
    end
    
    0 讨论(0)
  • 2020-12-18 19:29

    In the .rvm/gems/ruby-2.3.3/gems/active_record-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb file, Change the value of client_min_messages to anything other than panic. The valid values can be - debug5, debug4, debug3, debug2, debug1, log, notice, warning, error.

    The issue is with the newer versions of Postgresql adapter in ActiveRecord where panic is the new and the default value and old Postgres versions do not support that.

    0 讨论(0)
  • 2020-12-18 19:35

    I got this issue with Postgres 12.1 and I need to roll back to 9.4 and was solved.

    0 讨论(0)
  • 2020-12-18 19:39

    I had the exact same problem, and I finally figured out what it was. I grepped for the word "panic" inside of my gems folder, and got a hit in my ActiveRecord 4.2.2 gem, line 313. I monkey-patched the file, changing the value to "error", and I was then able to proceed with the db:create rake task. It seems likely that the ActiveRecord gem was changed, or the pg gem was changed, even though I'm using old, specific versions of both, because I was able to run db:create a few weeks ago, but now couldn't without this hack.

    TL;DR:

    gem info pg
    

    cd to the folder where it's installed (for me, ~/.rvm/gems/ruby-2.3.0/gems)

    grep -ri 'panic' .
    

    Replace anything related to pg with 'error' or some other valid message.

    0 讨论(0)
  • 2020-12-18 19:45

    I needed to make the following modifications to the monkey patch from @ruslan to work with Rails 4.2.4:

    require 'active_record/connection_adapters/postgresql_adapter'
    
    module ActiveRecord
      module ConnectionAdapters
        class PostgreSQLAdapter
          def set_standard_conforming_strings
            old, self.client_min_messages = client_min_messages, 'warning'
            execute('SET standard_conforming_strings = on', 'SCHEMA') rescue nil
          ensure
            self.client_min_messages = old
          end
        end
      end
    end
    
    0 讨论(0)
  • 2020-12-18 19:46

    I was also facing the same issue. I was using postgres 9.4.1 and upgraded to latest (12.1). Because of the version change, I got this issue. I reverted back to 9.4.1. Is that same with you as well?

    0 讨论(0)
提交回复
热议问题