Problem migrating from 2.3.5 to 3.3.1

As a transport layer for migrating single events i use a 2nd Server with Version 3.3.1 installed.
Imported the database dump and the file from the archive folder.
But when i run indico db upgrade i get the following error:
psycopg2.errors.DuplicateTable: relation “merge_map” already exists

In earlier version von Indico 3, the same operation worked perfectly for me.

Do you have any advice how to import from 2 to 3

Can you show the output of indico db upgrade. I have an idea since we use the same temp table in two revisions so w/o a commit in between it might fail.

You can try splittig it in two steps: First run indico db upgrade 735dc4e8d2f3, then indico db upgrade. That way you have a commit in between so the temp table disappears.

The workaround did it for me, thanks so much for your very quick response.

The whole output was:

(.venv) indico@conference3-standby:~$ indico db upgrade
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade e787389ca868 -> 26985db8ed12, Add attach_ical to reminders
INFO  [alembic.runtime.migration] Running upgrade 26985db8ed12 -> f26c201c8254, Add attach_ical to RegistrationForm
INFO  [alembic.runtime.migration] Running upgrade f26c201c8254 -> 3782de7970da, Rename oauth default_scopes
INFO  [alembic.runtime.migration] Running upgrade 3782de7970da -> da06d8f50342, Separate authorized scopes from tokens
INFO  [alembic.runtime.migration] Running upgrade da06d8f50342 -> c36abe1c23c7, Make OAuth PKCE flow configurable
INFO  [alembic.runtime.migration] Running upgrade c36abe1c23c7 -> d354278c6d95, Store tokens as hashes
INFO  [alembic.runtime.migration] Running upgrade d354278c6d95 -> ecc7088914e7, Use cascading FKs for oauth
INFO  [alembic.runtime.migration] Running upgrade ecc7088914e7 -> 26806768cd3f, Remove Flower oauth app
INFO  [alembic.runtime.migration] Running upgrade 26806768cd3f -> d89585afaf2e, Add index on user merged_into_id
INFO  [alembic.runtime.migration] Running upgrade d89585afaf2e -> cf9e1b4e2f5f, Restrict event creation if cat has subcats
INFO  [alembic.runtime.migration] Running upgrade cf9e1b4e2f5f -> 178d297eae7e, Disallow seconds in durations
INFO  [alembic.runtime.migration] Running upgrade 178d297eae7e -> 735dc4e8d2f3, Update merged users in registrations
INFO  [alembic.runtime.migration] Running upgrade 735dc4e8d2f3 -> fda76e047e87, Make sure contributions have titles
INFO  [alembic.runtime.migration] Running upgrade fda76e047e87 -> 79e770865675, Add more FTS indexes
INFO  [alembic.runtime.migration] Running upgrade 79e770865675 -> 90384b9b3d22, Make room division non-nullable
INFO  [alembic.runtime.migration] Running upgrade 90384b9b3d22 -> 356b8985ae7c, Add anonymous_submissions table for surveys
INFO  [alembic.runtime.migration] Running upgrade 356b8985ae7c -> 1f6738730753, Add personal access tokens
INFO  [alembic.runtime.migration] Running upgrade 1f6738730753 -> 1b7e98f581bc, Make token scopes not nullable
INFO  [alembic.runtime.migration] Running upgrade 1b7e98f581bc -> 5cbb0eb12eb3, Add last_used_ip and use_count to tokens
INFO  [alembic.runtime.migration] Running upgrade 5cbb0eb12eb3 -> 420195768776, Add reminder send_to_speakers column
INFO  [alembic.runtime.migration] Running upgrade 420195768776 -> cd3fef2095b4, Add is_flat_view_enabled setting for categories
INFO  [alembic.runtime.migration] Running upgrade cd3fef2095b4 -> 1cec32e42f65, Add reviewed_dt to paper revisions
INFO  [alembic.runtime.migration] Running upgrade 1cec32e42f65 -> 4b097412a8d9, Add category logs
INFO  [alembic.runtime.migration] Running upgrade 4b097412a8d9 -> 9d00917b2fa8, Add event category request
INFO  [alembic.runtime.migration] Running upgrade 9d00917b2fa8 -> dc53d6e8c576, Make event category nullable
INFO  [alembic.runtime.migration] Running upgrade dc53d6e8c576 -> b36825c7869e, Add registration tags
INFO  [alembic.runtime.migration] Running upgrade b36825c7869e -> 8993132179d3, Ensure single_choice fields have item_type
INFO  [alembic.runtime.migration] Running upgrade 8993132179d3 -> 84874a17eaf3, Cleanup registration fields is_billable
INFO  [alembic.runtime.migration] Running upgrade 84874a17eaf3 -> 3dafee32ba7d, Remove is_billable from registration fields
INFO  [alembic.runtime.migration] Running upgrade 3dafee32ba7d -> 82fb6c6ac6db, Add publish registrations with consent
INFO  [alembic.runtime.migration] Running upgrade 82fb6c6ac6db -> ef7a8b2e6737, Add access column to menu entries
INFO  [alembic.runtime.migration] Running upgrade ef7a8b2e6737 -> 5123f24eb41e, Add retention period to RegistrationFormItem
INFO  [alembic.runtime.migration] Running upgrade 5123f24eb41e -> 57696d76f9b0, Add registration visibility override
INFO  [alembic.runtime.migration] Running upgrade 57696d76f9b0 -> a61ce4bd7549, Add publish registrations duration to registration forms
INFO  [alembic.runtime.migration] Running upgrade a61ce4bd7549 -> 88eb87ee0d3e, Add retention period to RegistrationForm
INFO  [alembic.runtime.migration] Running upgrade 88eb87ee0d3e -> a707753d16e2, Add 'is_purged' flag to registration forms
INFO  [alembic.runtime.migration] Running upgrade a707753d16e2 -> 812aa90a3660, Add favorite events table
INFO  [alembic.runtime.migration] Running upgrade 812aa90a3660 -> c39db219f85a, Add predefined affiliations
INFO  [alembic.runtime.migration] Running upgrade c39db219f85a -> 1950e5d12ab5, Add predefined affiliations to persons
INFO  [alembic.runtime.migration] Running upgrade 1950e5d12ab5 -> 0c4bb2973536, Move affiliation into users table
INFO  [alembic.runtime.migration] Running upgrade 0c4bb2973536 -> 33c3ab67d729, Add registration created_by_manager column
INFO  [alembic.runtime.migration] Running upgrade 33c3ab67d729 -> b60f5c45acf7, Add require_captcha to regforms
INFO  [alembic.runtime.migration] Running upgrade b60f5c45acf7 -> b45847c0e62f, Add event series title pattern
INFO  [alembic.runtime.migration] Running upgrade b45847c0e62f -> 7551bd141960, Fix purged accommodation fields
INFO  [alembic.runtime.migration] Running upgrade 7551bd141960 -> 5d05eda06776, Add undone state to editing revisions
INFO  [alembic.runtime.migration] Running upgrade 5d05eda06776 -> 9b3fc740b722, Fix user name_format values
INFO  [alembic.runtime.migration] Running upgrade 9b3fc740b722 -> aba7935f9226, Add is_event_not_happening to EventLabel
INFO  [alembic.runtime.migration] Running upgrade aba7935f9226 -> e47fc6634291, Add menu entry ACLs
INFO  [alembic.runtime.migration] Running upgrade e47fc6634291 -> a59688f9ba40, Add require_privacy_policy_agreement to regforms
INFO  [alembic.runtime.migration] Running upgrade a59688f9ba40 -> 0af8f63aa603, Refactor editing revisions
INFO  [alembic.runtime.migration] Running upgrade 0af8f63aa603 -> cb46beecbb93, Add Editable.is_deleted
INFO  [alembic.runtime.migration] Running upgrade cb46beecbb93 -> cd7038a37646, Add internal_note column to room bookings
INFO  [alembic.runtime.migration] Running upgrade cd7038a37646 -> 0c44046dc1be, Add generate accompanying person tickets
INFO  [alembic.runtime.migration] Running upgrade 0c44046dc1be -> d8562ad31e90, Add created_dt on User model
INFO  [alembic.runtime.migration] Running upgrade d8562ad31e90 -> 13d8ba15a83b, Add recurrence_weekdays to reservations
INFO  [alembic.runtime.migration] Running upgrade 13d8ba15a83b -> 155cfc134f0c, Setting for future events threshold
INFO  [alembic.runtime.migration] Running upgrade 155cfc134f0c -> 31b699664893, Add modified date to editing revisions
INFO  [alembic.runtime.migration] Running upgrade 31b699664893 -> 0acf26d68434, Add subcontrib_speakers_can_submit to events table
INFO  [alembic.runtime.migration] Running upgrade 0acf26d68434 -> 252d61f890a0, Add receipt data structures
INFO  [alembic.runtime.migration] Running upgrade 252d61f890a0 -> fb0ca1440185, Add a redirect URI for the new Check-in app
INFO  [alembic.runtime.migration] Running upgrade fb0ca1440185 -> e2b69fe5155d, Add data_export_requests table
INFO  [alembic.runtime.migration] Running upgrade e2b69fe5155d -> 8e08236a529f, Add skip_access_check to invitations
INFO  [alembic.runtime.migration] Running upgrade 8e08236a529f -> 5bb555dd91eb, Update merged users in abstract email logs
Traceback (most recent call last):
  File "/opt/indico/.venv/lib/python3.12/site-packages/sqlalchemy/engine/", line 1910, in _execute_context
  File "/opt/indico/.venv/lib/python3.12/site-packages/sqlalchemy/engine/", line 736, in do_execute
    cursor.execute(statement, parameters)
psycopg2.errors.DuplicateTable: relation "merge_map" already exists

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/indico/.venv/bin/indico", line 8, in <module>
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/", line 1078, in main
    rv = self.invoke(ctx)
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/cli/", line 108, in invoke
    return self._impl.invoke(ctx)
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask/", line 388, in decorator
    return ctx.invoke(f, *args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/cli/", line 139, in _call_with_plugins
    func(*args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask/", line 388, in decorator
    return ctx.invoke(f, *args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask_migrate/", line 150, in upgrade
    _upgrade(directory, revision, sql, tag, x_arg)
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask_migrate/", line 111, in wrapped
    f(*args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask_migrate/", line 200, in upgrade
    command.upgrade(config, revision, sql=sql, tag=tag)
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/", line 403, in upgrade
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/script/", line 583, in run_env
    util.load_python_file(self.dir, "")
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/util/", line 95, in load_python_file
    module = load_module_py(module_id, path)
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/util/", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/migrations/", line 91, in <module>
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/migrations/", line 83, in run_migrations_online
  File "<string>", line 8, in run_migrations
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/runtime/", line 948, in run_migrations
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/runtime/", line 627, in run_migrations
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/migrations/versions/", line 19, in upgrade
  File "<string>", line 8, in execute
  File "<string>", line 3, in execute
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/operations/", line 2537, in execute
    return operations.invoke(op)
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/operations/", line 445, in invoke
    return fn(self, operation)
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/operations/", line 224, in execute_sql
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/ddl/", line 214, in execute
    self._exec(sql, execution_options)
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/ddl/", line 207, in _exec
    return conn.execute(construct, multiparams)
  File "/opt/indico/.venv/lib/python3.12/site-packages/sqlalchemy/engine/", line 1385, in execute
    return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
  File "/opt/indico/.venv/lib/python3.12/site-packages/sqlalchemy/sql/", line 334, in _execute_on_connection
    return connection._execute_clauseelement(
  File "/opt/indico/.venv/lib/python3.12/site-packages/sqlalchemy/engine/", line 1577, in _execute_clauseelement
    ret = self._execute_context(
  File "/opt/indico/.venv/lib/python3.12/site-packages/sqlalchemy/engine/", line 1953, in _execute_context
  File "/opt/indico/.venv/lib/python3.12/site-packages/sqlalchemy/engine/", line 2134, in _handle_dbapi_exception
  File "/opt/indico/.venv/lib/python3.12/site-packages/sqlalchemy/util/", line 211, in raise_
    raise exception
  File "/opt/indico/.venv/lib/python3.12/site-packages/sqlalchemy/engine/", line 1910, in _execute_context
  File "/opt/indico/.venv/lib/python3.12/site-packages/sqlalchemy/engine/", line 736, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateTable) relation "merge_map" already exists

        WITH RECURSIVE merge_map (user_id, current_user_id) AS (
            SELECT id, id FROM users.users WHERE merged_into_id IS NULL
            UNION ALL
            SELECT, mm.current_user_id FROM users.users u, merge_map mm WHERE u.merged_into_id = mm.user_id
        ) SELECT * FROM merge_map WHERE user_id != current_user_id;

        CREATE INDEX ix_merge_map_current_user_id ON merge_map USING btree (current_user_id);

        UPDATE event_abstracts.email_logs eml
        SET user_id = mm.current_user_id
        FROM merge_map mm
        WHERE mm.user_id = eml.user_id AND mm.current_user_id != eml.user_id;
(Background on this error at:

OK thanks, will fix that in the next release.

Will be fixed in v3.3.3: Fix error during direct DB upgrade from v2 to v3.3 · indico/indico@61aacd1 · GitHub

Of course hopefully nobody will encounter that error in the meantime, because nobody should be on v2 anymore since that means they’re using a 3-year-old version on an obsolete and unsupported Python version… :wink: