ERROR: must be owner of language plpgsql

后端 未结 5 1507
逝去的感伤
逝去的感伤 2021-02-18 13:46

I\'m using PostgreSQL v9.0.1 with Rails (and it\'s deps) @ v2.3.8, owing to the use of the fulltext capability of postgres, I have a table

5条回答
  •  天涯浪人
    2021-02-18 14:27

    I just filter the plpgsql extension statements from the structure.sql file post-dump:

    # lib/tasks/db.rake
    
    namespace :db do
      desc "Fix 'ERROR:  must be owner of extension plpgsql' complaints from Postgresql"
      task :fix_psql_dump do |task|
        filename = ENV['DB_STRUCTURE'] || File.join(ActiveRecord::Tasks::DatabaseTasks.db_dir, "structure.sql")
        sql = File.read(filename)
        sql.sub!(/(CREATE EXTENSION IF NOT EXISTS plpgsql)/, '-- \1')
        sql.sub!(/(COMMENT ON EXTENSION plpgsql)/, '-- \1')
        File.open(filename, 'w') do |f|
          f.write(sql)
        end
        task.reenable
      end
    end
    
    Rake::Task["db:structure:dump"].enhance do
      Rake::Task["db:fix_psql_dump"].invoke
    end
    

提交回复
热议问题