Bug #22807
closeddb:migrate still fails at 20160113162007_expand_all_template_invocations.rb
Description
foreman-rake db:migrate fails at 20160113162007_expand_all_template_invocations even if 20180226095631_change_task_id_to_uuid is present.
20180226095631_change_task_id_to_uuid would fix the issue only if it was applied before 20160113162007_expand_all_template_invocations (what is actually a workaround here)
20160113162007 ExpandAllTemplateInvocations: migrating ===================rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedFunction: ERROR: operator does not exist: uuid = character varying
LINE 1: ...ations_join" ON "tasks_job_invocations_join"."id" = "job_inv...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "job_invocations"."id" AS t0_r0, "job_invocations"."targeting_id" AS t0_r1, "job_invocations"."job_name" AS t0_r2, "job_invocations"."task_id" AS t0_r3, "job_invocations"."task_group_id" AS t0_r4, "job_invocations"."triggering_id" AS t0_r5, "job_invocations"."description" AS t0_r6, "template_invocations"."id" AS t1_r0, "template_invocations"."template_id" AS t1_r1, "template_invocations"."job_invocation_id" AS t1_r2, "template_invocations"."effective_user" AS t1_r3, "template_invocations"."host_id" AS t1_r4, "template_invocations"."run_host_job_task_id" AS t1_r5, "targetings"."id" AS t2_r0, "targetings"."search_query" AS t2_r1, "targetings"."bookmark_id" AS t2_r2, "targetings"."user_id" AS t2_r3, "targetings"."targeting_type" AS t2_r4, "targetings"."created_at" AS t2_r5, "targetings"."updated_at" AS t2_r6, "targetings"."resolved_at" AS t2_r7, "foreman_tasks_tasks"."id" AS t3_r0, "foreman_tasks_tasks"."type" AS t3_r1, "foreman_tasks_tasks"."label" AS t3_r2, "foreman_tasks_tasks"."started_at" AS t3_r3, "foreman_tasks_tasks"."ended_at" AS t3_r4, "foreman_tasks_tasks"."state" AS t3_r5, "foreman_tasks_tasks"."result" AS t3_r6, "foreman_tasks_tasks"."external_id" AS t3_r7, "foreman_tasks_tasks"."parent_task_id" AS t3_r8, "foreman_tasks_tasks"."start_at" AS t3_r9, "foreman_tasks_tasks"."start_before" AS t3_r10, "foreman_tasks_tasks"."action" AS t3_r11, "foreman_tasks_locks"."id" AS t4_r0, "foreman_tasks_locks"."task_id" AS t4_r1, "foreman_tasks_locks"."name" AS t4_r2, "foreman_tasks_locks"."resource_type" AS t4_r3, "foreman_tasks_locks"."resource_id" AS t4_r4, "foreman_tasks_locks"."exclusive" AS t4_r5 FROM "job_invocations" INNER JOIN "targetings" ON "targetings"."id" = "job_invocations"."targeting_id" LEFT OUTER JOIN "template_invocations" ON "template_invocations"."job_invocation_id" = "job_invocations"."id" AND (host_id IS NULL) LEFT OUTER JOIN "foreman_tasks_tasks" "tasks_job_invocations_join" ON "tasks_job_invocations_join"."id" = "job_invocations"."task_id" LEFT OUTER JOIN "foreman_tasks_tasks" ON "foreman_tasks_tasks"."parent_task_id" = "tasks_job_invocations_join"."id" LEFT OUTER JOIN "foreman_tasks_locks" ON "foreman_tasks_locks"."task_id" = "foreman_tasks_tasks"."id" WHERE (targetings.resolved_at IS NOT NULL) ORDER BY job_invocations.id DESC
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:614:in `async_exec'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:614:in `block (2 levels) in exec_no_cache'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_loads'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:613:in `block in exec_no_cache'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block (2 levels) in log'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:611:in `block in log'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:603:in `log'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:612:in `exec_no_cache'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:599:in `execute_and_clear'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:79:in `exec_query'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:371:in `select'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:42:in `select_all'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/query_cache.rb:97:in `select_all'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/relation/finder_methods.rb:381:in `find_with_associations'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/relation.rb:667:in `exec_queries'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/relation.rb:546:in `load'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/relation.rb:255:in `records'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/relation/delegation.rb:39:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_remote_execution-1.4.5/db/migrate/20160113162007_expand_all_template_invocations.rb:17:in `up'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:795:in `exec_migration'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:776:in `block (2 levels) in migrate'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:775:in `block in migrate'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:408:in `with_connection'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:774:in `migrate'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:953:in `migrate'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:1230:in `block in execute_migration_in_transaction'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:1298:in `block in ddl_transaction'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `block in transaction'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:194:in `block in within_new_transaction'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:191:in `within_new_transaction'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `transaction'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/transactions.rb:210:in `transaction'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:1298:in `ddl_transaction'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:1229:in `execute_migration_in_transaction'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:1201:in `block in migrate_without_lock'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:1200:in `each'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:1200:in `migrate_without_lock'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:1148:in `block in migrate'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:1317:in `with_advisory_lock'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:1148:in `migrate'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:1007:in `up'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/migration.rb:985:in `migrate'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/opt/rh/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/opt/rh/rh-ruby24/root/usr/share/gems/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR: operator does not exist: uuid = character varying
LINE 1: ...ations_join" ON "tasks_job_invocations_join"."id" = "job_inv...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "job_invocations"."id" AS t0_r0, "job_invocations"."targeting_id" AS t0_r1, "job_invocations"."job_name" AS t0_r2, "job_invocations"."task_id" AS t0_r3, "job_invocations"."task_group_id" AS t0_r4, "job_invocations"."triggering_id" AS t0_r5, "job_invocations"."description" AS t0_r6, "template_invocations"."id" AS t1_r0, "template_invocations"."template_id" AS t1_r1, "template_invocations"."job_invocation_id" AS t1_r2, "template_invocations"."effective_user" AS t1_r3, "template_invocations"."host_id" AS t1_r4, "template_invocations"."run_host_job_task_id" AS t1_r5, "targetings"."id" AS t2_r0, "targetings"."search_query" AS t2_r1, "targetings"."bookmark_id" AS t2_r2, "targetings"."user_id" AS t2_r3, "targetings"."targeting_type" AS t2_r4, "targetings"."created_at" AS t2_r5, "targetings"."updated_at" AS t2_r6, "targetings"."resolved_at" AS t2_r7, "foreman_tasks_tasks"."id" AS t3_r0, "foreman_tasks_tasks"."type" AS t3_r1, "foreman_tasks_tasks"."label" AS t3_r2, "foreman_tasks_tasks"."started_at" AS t3_r3, "foreman_tasks_tasks"."ended_at" AS t3_r4, "foreman_tasks_tasks"."state" AS t3_r5, "foreman_tasks_tasks"."result" AS t3_r6, "foreman_tasks_tasks"."external_id" AS t3_r7, "foreman_tasks_tasks"."parent_task_id" AS t3_r8, "foreman_tasks_tasks"."start_at" AS t3_r9, "foreman_tasks_tasks"."start_before" AS t3_r10, "foreman_tasks_tasks"."action" AS t3_r11, "foreman_tasks_locks"."id" AS t4_r0, "foreman_tasks_locks"."task_id" AS t4_r1, "foreman_tasks_locks"."name" AS t4_r2, "foreman_tasks_locks"."resource_type" AS t4_r3, "foreman_tasks_locks"."resource_id" AS t4_r4, "foreman_tasks_locks"."exclusive" AS t4_r5 FROM "job_invocations" INNER JOIN "targetings" ON "targetings"."id" = "job_invocations"."targeting_id" LEFT OUTER JOIN "template_invocations" ON "template_invocations"."job_invocation_id" = "job_invocations"."id" AND (host_id IS NULL) LEFT OUTER JOIN "foreman_tasks_tasks" "tasks_job_invocations_join" ON "tasks_job_invocations_join"."id" = "job_invocations"."task_id" LEFT OUTER JOIN "foreman_tasks_tasks" ON "foreman_tasks_tasks"."parent_task_id" = "tasks_job_invocations_join"."id" LEFT OUTER JOIN "foreman_tasks_locks" ON "foreman_tasks_locks"."task_id" = "foreman_tasks_tasks"."id" WHERE (targetings.resolved_at IS NOT NULL) ORDER BY job_invocations.id DESC