Decidim: PG::UndefinedFunction: ERROR: operator does not exist: jsonb - unknown

Created on 4 Apr 2019  路  3Comments  路  Source: decidim/decidim

I was installing an instance of Decidim, and when I execute bin/rails db:migrate, it throws these messages:

...
== 20190404024613 RenameMaximumVotesPerProposalToThresholdPerProposal: migrating 
-- execute("UPDATE decidim_components\nSET settings = jsonb_set(\n  settings::jsonb,\n  array['global'],\n  (settings->'global')::jsonb - 'maximum_votes_per_proposal' || jsonb_build_object('threshold_per_proposal', settings->'global'->'maximum_votes_per_proposal')\n  )\nWHERE manifest_name = 'proposals'\n")
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedFunction: ERROR:  operator does not exist: jsonb - unknown
LINE 5:   (settings->'global')::jsonb - 'maximum_votes_per_proposal'...
                                      ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
: UPDATE decidim_components
SET settings = jsonb_set(
  settings::jsonb,
  array['global'],
  (settings->'global')::jsonb - 'maximum_votes_per_proposal' || jsonb_build_object('threshold_per_proposal', settings->'global'->'maximum_votes_per_proposal')
  )
WHERE manifest_name = 'proposals'

Error messages point to method up at line 6 in db/migrate/20190404024613_rename_maximum_votes_per_proposal_to_threshold_per_proposal.decidim.rb:

  def up
    execute <<~SQL
      UPDATE decidim_components
      SET settings = jsonb_set(
        settings::jsonb,
        array['global'],
        (settings->'global')::jsonb - 'maximum_votes_per_proposal' || jsonb_build_object('threshold_per_proposal', settings->'global'->'maximum_votes_per_proposal')
        )
      WHERE manifest_name = 'proposals'
    SQL
  end
wontfix

All 3 comments

Hi @israelbuitron! What version of PostgreSQL are you using?

Minimum required version is 9.5, as per https://github.com/decidim/decidim/blob/master/docs/manual-installation.md

@mrcasals Yes, I have installed PostgreSQL 9.5:

psql -V
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
psql (PostgreSQL) 9.5.16

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. @carolromero & @xabier feel free to chime in.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Xfolchf picture Xfolchf  路  4Comments

tramuntanal picture tramuntanal  路  4Comments

carolromero picture carolromero  路  3Comments

josanFFiG picture josanFFiG  路  3Comments

clauded picture clauded  路  3Comments