Cannot run zammad run rake db:migrate after upgrade

  • Used Zammad version: 4.1.0
  • Used Zammad installation type: Package
  • Operating system: Ubuntu 18.04
  • Browser + version: All browsers

I am trying to upgrade from version 3.6 to 4.1. The “apt upgrade” runs through without any errors but tickets are not shown and pages like webhooks does not get loaded. On tickets page I receive this error " Status Code: 422. {“error”:“PG::UndefinedTable: ERROR: relation “mentions” does not exist\nLINE 8: WHERE a.attrelid = ‘“mentions”’::regclass\n ^\n: SELECT a.attname, formattype(a.atttypid, a.atttypmod),\n pggetexpr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,\n c.collname, coldescription(a.attrelid, a.attnum) AS…"
So I tried “zammad run rake db:migrate” as mentioned here https://community.zammad.org/t/status-code-422-on-tickets-after-update-to-newest-version-4/6550 but that does not work at all.

Expected behavior:

  • I can migrate the db

Actual behavior:

  • Migration gets aborted
zammad run rake db:migrate
== 20201110000001 MentionInit: migrating ======================================
-- create_table(:mentions)
   -> 0.1220s
-- add_index(:mentions, [:mentionable_id, :mentionable_type, :user_id], {:unique=>true, :name=>"index_mentions_mentionable_user"})
   -> 0.0062s
-- add_foreign_key(:mentions, :users, {:column=>:created_by_id})
   -> 0.0036s
-- add_foreign_key(:mentions, :users, {:column=>:updated_by_id})
   -> 0.0018s
-- add_foreign_key(:mentions, :users, {:column=>:user_id})
   -> 0.0020s
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Validation failed: Image source is invalid
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/validations.rb:80:in `raise_validation_error'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/validations.rb:52:in `save!'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:315:in `block in save!'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:387:in `block in with_transaction_returning_status'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/database_statements.rb:265:in `transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:212:in `transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:385:in `with_transaction_returning_status'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:315:in `save!'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/suppressor.rb:48:in `save!'
/opt/zammad/db/migrate/20201110000001_mention_init.rb:54:in `block in update_users'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/relation/delegation.rb:71:in `each'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/relation/delegation.rb:71:in `each'
/opt/zammad/db/migrate/20201110000001_mention_init.rb:47:in `update_users'
/opt/zammad/db/migrate/20201110000001_mention_init.rb:21:in `change'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:814:in `exec_migration'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:797:in `block in migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:796:in `migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:977:in `migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1343:in `block in ddl_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `block in transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:212:in `transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1343:in `ddl_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1262:in `each'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1210:in `block in migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1210:in `migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1036:in `up'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1011:in `migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <main>'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `load'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `kernel_load'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:28:in `run'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:463:in `exec'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:27:in `dispatch'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:18:in `start'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/exe/bundle:30:in `block in <top (required)>'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/exe/bundle:22:in `<top (required)>'
/opt/zammad/bin/bundle:3:in `load'
/opt/zammad/bin/bundle:3:in `<main>'

Caused by:
ActiveRecord::RecordInvalid: Validation failed: Image source is invalid
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/validations.rb:80:in `raise_validation_error'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/validations.rb:52:in `save!'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:315:in `block in save!'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:387:in `block in with_transaction_returning_status'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/database_statements.rb:265:in `transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:212:in `transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:385:in `with_transaction_returning_status'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:315:in `save!'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/suppressor.rb:48:in `save!'
/opt/zammad/db/migrate/20201110000001_mention_init.rb:54:in `block in update_users'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/relation/delegation.rb:71:in `each'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/relation/delegation.rb:71:in `each'
/opt/zammad/db/migrate/20201110000001_mention_init.rb:47:in `update_users'
/opt/zammad/db/migrate/20201110000001_mention_init.rb:21:in `change'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:814:in `exec_migration'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:798:in `block (2 levels) in migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:797:in `block in migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:796:in `migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:977:in `migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1292:in `block in execute_migration_in_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1343:in `block in ddl_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `block in transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/connection_adapters/abstract/database_statements.rb:267:in `transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/transactions.rb:212:in `transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1343:in `ddl_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1291:in `execute_migration_in_transaction'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1263:in `block in migrate_without_lock'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1262:in `each'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1262:in `migrate_without_lock'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1210:in `block in migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1363:in `with_advisory_lock'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1210:in `migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1036:in `up'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/migration.rb:1011:in `migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.4.6/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <main>'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `load'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `kernel_load'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:28:in `run'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:463:in `exec'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:27:in `dispatch'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:18:in `start'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/exe/bundle:30:in `block in <top (required)>'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/exe/bundle:22:in `<top (required)>'
/opt/zammad/bin/bundle:3:in `load'
/opt/zammad/bin/bundle:3:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)



### Steps to reproduce the behavior:

* apt update
apt upgrade
zammad run rake db:migrate

You’re affected by this bug:

Very dirty workaround would be the following.

Dangerzone

Dear future anon finding this post

Please be aware that the following operation is dangerous and can potentially harm your installation. Only run this command if you are 1 0 0 0 % SURE you’re affected by the issue described in above linked issue. Have a backup.

zammad run rails r "User.where.not(image_source: nil).update_all(image_source: '')"

Thanks for the quick reply.

The workaround did the trick in my test environment. But I think I’ll wait with updating the production environment until the bug is officially closed.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.