DB Post Migrate - CleanupProjectsWithMissingNamespace - Operator is not unique, explicit cast required
When trying to run db post migrate operations this error shows up:
== 20200511083541 CleanupProjectsWithMissingNamespace: migrating ==============
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
PG::AmbiguousFunction: ERROR: operator is not unique: text || integer
LINE 8: name = name || '_' || id,
^
HINT: Could not choose a best candidate operator. You might need to add explicit type casts.
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `exec_params'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `block (2 levels)
in exec_no_cache'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads
'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:674:in `block in exec_no_
cache'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:722:in `block (2 levels) in
log'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 level
s) in synchronize'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interru
pt'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synch
ronize'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interru
pt'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:721:in `block in log'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:712:in `log'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:673:in `exec_no_cache'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:654:in `execute_and_clear
'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/marginalia-1.8.0/lib/marginalia.rb:94:in `execute_and_clear_with_marginalia'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:111:in `exec_
delete'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:174:in `update'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/connection_adapters/abstract/query_cache.rb:22:in `update'
/opt/gitlabhq-13.0/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3/lib/active_record/relation.rb:469:in `update_all'
/opt/gitlabhq-13.0/db/post_migrate/20200511083541_cleanup_projects_with_missing_namespace.rb:244:in `block in up'
/opt/gitlabhq-13.0/app/models/concerns/each_batch.rb:90:in `block in each_batch'
/opt/gitlabhq-13.0/app/models/concerns/each_batch.rb:68:in `step'
/opt/gitlabhq-13.0/app/models/concerns/each_batch.rb:68:in `each_batch'
/opt/gitlabhq-13.0/db/post_migrate/20200511083541_cleanup_projects_with_missing_namespace.rb:243:in `up'
Testing here, simply adding ::text cast to everything in lines 252 and 253 fixed the issue:
name = name::text || '_'::text || id::text,
path = path::text || '_'::text || id::text