PG::DuplicateColumn: ERROR: column "location" of relation "knowledge_base_menu_items" already exists

Infos:

  • Used Zammad version: 5.0.X
  • Used Zammad installation type: (source, package, docker-compose, …) source
  • Operating system: Debian GNU/Linux 9.13 (stretch)
  • Browser + version:

Expected behavior:

  • Recently I update my system, zammad and elasticsearch installation. When I tried to log in, I receive an error.

Actual behavior:

  • When I execute: zammad run rake db:migrate --trace

** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:migrate
== 20190918114553 Issue2867FooterHeaderPublicLink: migrating ==================
– add_column(:knowledge_base_menu_items, :location, :string, {:null=>false, :default=>“header”})
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateColumn: ERROR: column “location” of relation “knowledge_base_menu_items” already exists

When I execute:
zammad run rake db:version --trace
Current version: 20190903165443

Could you help me?

I search on /opt/zammad/db/migrate for a file with knowledge_base_menu_items text finding 20190918114553_issue_2867_footer_header_public_link.rb.

I commented all functions inside and re-run zammad run rake db:migrate --trace.

It ends whitout errors and I can log in again.

Dear future anon finding this thread.
Please note that changing migration files is not a safe operation and might break your systems database or draw you in an state that’s unrecoverable and causes a bricked Zammad installation.

Continue with absolute caution. Above may be a workaround but is not a solution.

I commented those functions after verifying that those fields already existed in the database and after having a Zammad installation inoperative for 4 days.

During those days I performed many tasks including the manual execution of the update of that particular script. :slightly_smiling_face: