Skip to content

database downgrade from dev to 25.0 fails #20725

@mvdbeek

Description

@mvdbeek
❯ ./manage_db.sh downgrade release_25.0
Activating virtualenv at .venv
/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/edam_ontology/streams.py:8: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  from pkg_resources import resource_stream
INFO:alembic.runtime.migration:Context impl PostgresqlImpl.
INFO:alembic.runtime.migration:Will assume transactional DDL.
INFO:alembic.runtime.migration:Running downgrade 3af58c192752 -> 338d0e5deb03, Implement sample sheets
DEBUG:alembic.runtime.migration:update 3af58c192752 to 338d0e5deb03
INFO:alembic.runtime.migration:Running downgrade 338d0e5deb03 -> c44ae5f3dcf1, Add cleanup_event_user_assoc table
Traceback (most recent call last):
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
    ~~~~~~~~~~~~~~~~~~~~~~~^
        cursor, str_statement, effective_parameters, context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/sqlalchemy/engine/default.py", line 945, in do_execute
    cursor.execute(statement, parameters)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedTable: table "cleanup_event_user_association" does not exist


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

Traceback (most recent call last):
  File "/Users/mvandenb/src/galaxy/./scripts/db.py", line 37, in <module>
    main()
    ~~~~^^
  File "/Users/mvandenb/src/galaxy/./scripts/db.py", line 33, in main
    args.func(args)
    ~~~~~~~~~^^^^^^
  File "/Users/mvandenb/src/galaxy/lib/galaxy/model/migrations/base.py", line 266, in downgrade
    self._exec_command("downgrade", args)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/Users/mvandenb/src/galaxy/lib/galaxy/model/migrations/base.py", line 287, in _exec_command
    getattr(dbscript, command)(args)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Users/mvandenb/src/galaxy/lib/galaxy/model/migrations/base.py", line 205, in downgrade
    command.downgrade(self.alembic_config, revision, args.sql)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/alembic/command.py", line 455, in downgrade
    script.run_env()
    ~~~~~~~~~~~~~~^^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/alembic/script/base.py", line 586, in run_env
    util.load_python_file(self.dir, "env.py")
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/Users/mvandenb/src/galaxy/lib/galaxy/model/migrations/alembic/env.py", line 157, in <module>
    run_migrations_online()
    ~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/mvandenb/src/galaxy/lib/galaxy/model/migrations/alembic/env.py", line 40, in run_migrations_online
    _configure_and_run_migrations_online(url)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/Users/mvandenb/src/galaxy/lib/galaxy/model/migrations/alembic/env.py", line 121, in _configure_and_run_migrations_online
    _run_migrations()
    ~~~~~~~~~~~~~~~^^
  File "/Users/mvandenb/src/galaxy/lib/galaxy/model/migrations/alembic/env.py", line 128, in _run_migrations
    context.run_migrations()
    ~~~~~~~~~~~~~~~~~~~~~~^^
  File "<string>", line 8, in run_migrations
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/alembic/runtime/environment.py", line 946, in run_migrations
    self.get_context().run_migrations(**kw)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/alembic/runtime/migration.py", line 623, in run_migrations
    step.migration_fn(**kw)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/Users/mvandenb/src/galaxy/lib/galaxy/model/migrations/alembic/versions_gxy/338d0e5deb03_add_cleanup_event_user_assoc_table.py", line 44, in downgrade
    drop_table(TABLE_NAME)
    ~~~~~~~~~~^^^^^^^^^^^^
  File "/Users/mvandenb/src/galaxy/lib/galaxy/model/migrations/util.py", line 305, in drop_table
    DropTable(table_name).run()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/mvandenb/src/galaxy/lib/galaxy/model/migrations/util.py", line 28, in run
    return self.execute()
           ~~~~~~~~~~~~^^
  File "/Users/mvandenb/src/galaxy/lib/galaxy/model/migrations/util.py", line 111, in execute
    op.drop_table(self.table_name)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "<string>", line 8, in drop_table
  File "<string>", line 3, in drop_table
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/alembic/operations/ops.py", line 1421, in drop_table
    operations.invoke(op)
    ~~~~~~~~~~~~~~~~~^^^^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/alembic/operations/base.py", line 441, in invoke
    return fn(self, operation)
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/alembic/operations/toimpl.py", line 84, in drop_table
    operations.impl.drop_table(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^
        operation.to_table(operations.migration_context), **kw
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/alembic/ddl/impl.py", line 428, in drop_table
    self._exec(schema.DropTable(table, **kw))
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/alembic/ddl/impl.py", line 246, in _exec
    return conn.execute(construct, params)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1416, in execute
    return meth(
        self,
        distilled_parameters,
        execution_options or NO_OPTIONS,
    )
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/sqlalchemy/sql/ddl.py", line 187, in _execute_on_connection
    return connection._execute_ddl(
           ~~~~~~~~~~~~~~~~~~~~~~~^
        self, distilled_params, execution_options
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1527, in _execute_ddl
    ret = self._execute_context(
        dialect,
    ...<4 lines>...
        compiled,
    )
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1843, in _execute_context
    return self._exec_single_context(
           ~~~~~~~~~~~~~~~~~~~~~~~~~^
        dialect, context, statement, parameters
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1983, in _exec_single_context
    self._handle_dbapi_exception(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        e, str_statement, effective_parameters, cursor, context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 2352, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
    ~~~~~~~~~~~~~~~~~~~~~~~^
        cursor, str_statement, effective_parameters, context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/mvandenb/src/galaxy/.venv/lib/python3.13/site-packages/sqlalchemy/engine/default.py", line 945, in do_execute
    cursor.execute(statement, parameters)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) table "cleanup_event_user_association" does not exist

[SQL:
DROP TABLE cleanup_event_user_association]
(Background on this error at: https://sqlalche.me/e/20/f405)

I think that used to be a table created by external scripts ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions