Bug description
Hi Team, I am trying to upgrade superset version from 4.1.1 to 5.0.0 and getting below error. Alembic version of old DB is 48cbb571fa3a
Upgrading DB schema...
Loaded your LOCAL configuration at [/app/pythonpath/superset_config.py]
2025-07-27 05:45:45,326:INFO:superset.initialization:Setting database isolation level to READ COMMITTED
/app/.venv/lib/python3.11/site-packages/flask_limiter/extension.py:333: UserWarning: Using the in-memory storage for tracking rate limits as no storage was explicitly specified. This is not recommended for production use. See: https://flask-limiter.readthedocs.io#configuring-a-storage-backend for documentation about configuring the storage backend.
warnings.warn(
2025-07-27 05:45:45,501:INFO:superset.utils.screenshots:No PIL installation found
2025-07-27 05:45:46,207:INFO:superset.utils.pdf:No PIL installation found
INFO [alembic.env] Starting the migration scripts.
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> 4e6a06bad7a8, Init
Traceback (most recent call last):
File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1910, in _execute_context
self.dialect.do_execute(
File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.DuplicateTable: relation "dashboards" already exists
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/.venv/bin/superset", line 10, in
sys.exit(superset())
^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in call
return self.main(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/flask/cli.py", line 358, in decorator
return ctx.invoke(f, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/flask_migrate/cli.py", line 149, in upgrade
_upgrade(directory, revision, sql, tag, x_arg)
File "/app/.venv/lib/python3.11/site-packages/flask_migrate/init.py", line 98, in wrapped
f(*args, kwargs)
File "/app/.venv/lib/python3.11/site-packages/flask_migrate/__init.py", line 185, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/app/.venv/lib/python3.11/site-packages/alembic/command.py", line 406, in upgrade
script.run_env()
File "/app/.venv/lib/python3.11/site-packages/alembic/script/base.py", line 586, in run_env
util.load_python_file(self.dir, "env.py")
File "/app/.venv/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
module = load_module_py(module_id, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
spec.loader.exec_module(module) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 940, in exec_module
File "", line 241, in call_with_frames_removed
File "/app/.venv/lib/python3.11/site-packages/superset/extensions/../migrations/env.py", line 142, in
run_migrations_online()
File "/app/.venv/lib/python3.11/site-packages/superset/extensions/../migrations/env.py", line 133, in run_migrations_online
context.run_migrations()
File "", line 8, in run_migrations
File "/app/.venv/lib/python3.11/site-packages/alembic/runtime/environment.py", line 946, in run_migrations
self.get_context().run_migrations(kw)
File "/app/.venv/lib/python3.11/site-packages/alembic/runtime/migration.py", line 623, in run_migrations
step.migration_fn(kw)
File "/app/.venv/lib/python3.11/site-packages/superset/migrations/versions/2015-09-21_17-30_4e6a06bad7a8_init.py", line 57, in upgrade
op.create_table(
File "", line 8, in create_table
File "", line 3, in create_table
File "/app/.venv/lib/python3.11/site-packages/alembic/operations/ops.py", line 1318, in create_table
return operations.invoke(op)
^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/alembic/operations/base.py", line 442, in invoke
return fn(self, operation)
^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/alembic/operations/toimpl.py", line 143, in create_table
operations.impl.create_table(table, kw)
File "/app/.venv/lib/python3.11/site-packages/alembic/ddl/impl.py", line 406, in create_table
self._exec(schema.CreateTable(table, kw))
File "/app/.venv/lib/python3.11/site-packages/alembic/ddl/impl.py", line 247, in _exec
return conn.execute(construct, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1385, in execute
return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection
return connection._execute_ddl(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1477, in _execute_ddl
ret = self._execute_context(
^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1953, in _execute_context
self._handle_dbapi_exception(
File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2134, in _handle_dbapi_exception
util.raise(
File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
raise exception
File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1910, in _execute_context
self.dialect.do_execute(
File "/app/.venv/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateTable) relation "dashboards" already exists
[SQL:
CREATE TABLE dashboards (
created_on TIMESTAMP WITHOUT TIME ZONE NOT NULL,
changed_on TIMESTAMP WITHOUT TIME ZONE NOT NULL,
id SERIAL NOT NULL,
dashboard_title VARCHAR(500),
position_json TEXT,
created_by_fk INTEGER,
changed_by_fk INTEGER,
PRIMARY KEY (id),
FOREIGN KEY(created_by_fk) REFERENCES ab_user (id),
FOREIGN KEY(changed_by_fk) REFERENCES ab_user (id)
)
]
(Background on this error at: https://sqlalche.me/e/14/f405)
Screenshots/recordings
No response
Superset version
5.0.0
Python version
3.11
Node version
18 or greater
Browser
Chrome
Additional context
No response
Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
The error happens because Alembic thinks your metadata database is uninitialized—it’s trying to run the very first migration, which creates tables like dashboards that already exist. This usually means the alembic_version table in your metadata DB is missing, empty, or has the wrong value. Superset relies on this table to know which migrations have already run; if it’s out of sync, you’ll get “table already exists” errors when upgrading see migration script.
To fix:
1. Back up your metadata database.
2. Inspect the alembic_version table (e.g., SELECT * FROM alembic_version;
).
- If it’s missing, create it:
sql
CREATE TABLE alembic_version (version_num VARCHAR(32) NOT NULL);
- If it’s empty or wrong, set it to your last known good revision (for you: 48cbb571fa3a
):
sql
DELETE FROM alembic_version;
INSERT INTO alembic_version (version_num) VALUES ('48cbb571fa3a');
3. Re-run superset db upgrade
.
If you’ve had failed or partial migrations before, your schema might be inconsistent—consider testing the upgrade on a DB copy first. The official docs don’t require any special steps for this upgrade path docs.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
