DB error migrating from 1.2 to 2.0


Dear all,

we have been tying to upgrade in a TEST environment our current instance of Indico, but when we run the " indico-migrate" we get this error:

Trying to open file:///opt/indico-legacy/db/Data.fs...
*** Your database is not empty!
*** If you want to reset it, please drop and recreate it first.

Following your documentation (https://docs.getindico.io/en/latest/installation/production/centos/apache/) we proceeded as follows:

  1. We have a new CentOs machine where we are going to run the new version of Indico.
  2. In the CentOs machine > /opt/indico-legacy we copied the /opt/indico folder of our old OpenSuse machine where the Indico 1.2 is still running.
  3. We installed the Indico 2.1 using " pip install ‘indico<2.1’"
    4 .We run “indico db prepare”
  4. Activated the services. And we get the Indico up and running.
  5. We started the " indico-migrate" and we get the error (*** Your database is not empty!).

We dropped the schemas and the migrate script fails because it needs categories.

Could you please tell us how to proceed? May we need to revert the installation in this new machine and start again migrating the old data before create the postgres DB.

Thanks for your help!!

Isidre Costa
ALBA Synchrotron


You need an empty database, so you should not have run indico db prepare. Please delete and recreate your database and try again.

If you get some error related to categories with an empty DB, please post that error.



we dropped all the shcemas from the DB. Now we have these ones:

indico=> select schema_name
from information_schema.schemata;
(3 rows)

Then we run the migrate:

(.venv) [indico@indicodemo ~]$ indico-migrate postgresql:///indico file:///opt/indico-legacy/db/Data.fs --archive-dir /opt/indico-legacy/archive --storage-backend legacy --default-email indico@cells.es --default-currency EUR --symlink-target ~/archive/legacy_symlinks/ --symlink-backend legacy-symlinks --migrate-broken-events

And we get the following error:

raceback (most recent call last):
  File "/opt/indico/.venv/bin/indico-migrate", line 10, in <module>
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico_migrate/cli.py", line 126, in main
    return cli()
  File "/opt/indico/.venv/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/opt/indico/.venv/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/opt/indico/.venv/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/indico/.venv/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico_migrate/cli.py", line 122, in cli
    debug=debug, **kwargs)
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico_migrate/migrate.py", line 74, in migrate
    app, tz = setup(logger, zodb_root, sqlalchemy_uri, dblog=dblog, restore=(restore_file is not None))
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico_migrate/migrate.py", line 181, in setup
    if db_has_data():
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico_migrate/migrate.py", line 139, in db_has_data
    if getattr(db.m, model_name).query.has_rows():
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico/core/db/sqlalchemy/util/models.py", line 69, in has_rows
    return self.session.query(self.enable_eagerloads(False).exists()).scalar()
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2843, in scalar
    ret = self.one()
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2814, in one
    ret = self.one_or_none()
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2784, in one_or_none
    ret = list(self)
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2855, in __iter__
    return self._execute_and_instances(context)
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2878, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 945, in execute
    return meth(self, multiparams, params)
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
  File "/opt/indico/.venv/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "categories.categories" does not exist
LINE 2: FROM categories.categories) AS anon_1
 [SQL: 'SELECT EXISTS (SELECT 1 \nFROM categories.categories) AS anon_1']

Thank you for your help!!



What tables do you have in the public schema?


Your database must be completely empty. The only thing it should contain are the two extensions that are enabled during the setup steps.


Hi guys!

With an empty db, the migration works.

Thank you!!