Zammad 3.1.x to 3.2.0 update. PG::DuplicateTable: ERROR: relation "groups_macros" already exists

Centos 7.
Update from:
—> Package zammad.x86_64 0:3.1.0-1574093100.6fba2c9c.centos7 will be updated
—> Package zammad.x86_64 0:3.2.0-1575387475.16fc27bd.centos7 will be an update
Partial log:

Enabling Zammad on boot
Stopping Zammad
database.yml found. Updating db…
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateTable: ERROR: relation “groups_macros” already exists
: CREATE TABLE “groups_macros” (“macro_id” integer NOT NULL, “group_id” integer NOT NULL)
=============DELETED MANY LETTERS===================
Caused by:
PG::DuplicateTable: ERROR: relation “groups_macros” already exists
=============DELETED MANY LETTERS===================
.
After reboot helpdesk login is broken.
here is suspicious erro in production.log
===============================
I, [2019-12-03T21:33:48.034668 #6540-70161918437960] INFO – : execute Stats.generate (try_count 0)…
E, [2019-12-03T21:33:48.947157 #6540-70161918437960] ERROR – : execute Stats.generate (try_count 0) exited with error #<ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation “active_job_locks” does not exist
LINE 8: WHERE a.attrelid = ‘“active_job_locks”’::regc…
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
c.collname, col_description(a.attrelid, a.attnum) AS comment
FROM pg_attribute a
LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
LEFT JOIN pg_type t ON a.atttypid = t.oid
LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
WHERE a.attrelid = ‘“active_job_locks”’::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
in: 0.940594923 seconds.

Run zammad run db:migrate and try again.

Your database migration is incomplete and thus proberbly other migrations as well.

nope.
Copied my virtual machine for testing and did upgrade from zammad 3.1.1 to 3.2.0, and before uprade I did run:
zammad run rake db:migrate.
this command runs without any output.
Upgrade shows same error in command line:

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateTable: ERROR: relation “groups_macros” already exists
: CREATE TABLE “groups_macros” (“macro_id” integer NOT NULL, “group_id” integer NOT NULL)

Logins into helpdesk fail with this error:
2

Yes, because the migration was not successfull!
Run it manually:

zammad run db:migrate

[vkiesner@helpdesk ~]$ sudo zammad run rails 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
== 20190713000001 GroupDependentMacros: migrating =============================
– create_table(:groups_macros, {:id=>false})
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateTable: ERROR: relation “groups_macros” already exists
: CREATE TABLE “groups_macros” (“macro_id” integer NOT NULL, “group_id” integer NOT NULL)

here some info:
[root@zammad ~]# zammad run rake db:version
Current version: 20190626000001
Failed script, i think is: 20190713000001_group_dependent_macros.rb
But, when i did:
[root@zammad ~]# zammad run rake db:structure:dump
in db/structure.sql i can find following code ->

CREATE TABLE groups_macros (
macro_id integer NOT NULL,
group_id integer NOT NULL

I do not know, why my db already has group_macros update.
Is there a way to change db version, to skip this particular fix?

On test installation i deleted groups_macros table from database and upgrade to 3.2.0 pass OK.
As I understood, another way is to add into schema_migrations table new version value “20190713000001” and upgrade also must pass.

Is there any more civilized way to fix such issue? without direct db edit?

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