sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "account_plugin_permissions" does not exist
Self Checks
- [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [x] I have searched for existing issues search for existing issues, including closed ones.
- [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [x] Please do not modify this template :) and fill in all the required fields.
Dify version
1.0.0
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
Observe that the UI shows "Internal Server Error".
The console shows 500 INTERNAL SERVER ERROR for the following endpoints: /workspaces/current/plugin/permission/fetch
Here is the stack trace from the API:
`2025-03-11 01:11:34.152 ERROR [Dummy-134] [app.py:875] - Exception on /console/api/workspaces/current/plugin/permission/fetch [GET]
Traceback (most recent call last):
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
self.dialect.do_execute(
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.UndefinedTable: relation "account_plugin_permissions" does not exist
LINE 2: FROM account_plugin_permissions
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper
resp = resource(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
resp = meth(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/app/api/controllers/console/wraps.py", line 147, in decorated
return view(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/app/api/libs/login.py", line 94, in decorated_view
return current_app.ensure_sync(func)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/controllers/console/wraps.py", line 27, in decorated
return view(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/app/api/controllers/console/workspace/plugin.py", line 437, in get
permission = PluginPermissionService.get_permission(tenant_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/plugin/plugin_permission_service.py", line 11, in get_permission
return session.query(TenantPluginPermission).filter(TenantPluginPermission.tenant_id == tenant_id).first()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2728, in first
return self.limit(1)._iter().first() # type: ignore
^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2827, in _iter
result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(
^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2362, in execute
return self._execute_internal(
^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2247, in _execute_internal
result: Result[Any] = compile_state_cls.orm_execute_statement(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/orm/context.py", line 305, in orm_execute_statement
result = conn.execute(
^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1418, in execute
return meth(
^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/sql/elements.py", line 515, in _execute_on_connection
return connection._execute_clauseelement(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1640, in _execute_clauseelement
ret = self._execute_context(
^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
return self._exec_single_context(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context
self._handle_dbapi_exception(
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2355, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
self.dialect.do_execute(
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "account_plugin_permissions" does not exist
LINE 2: FROM account_plugin_permissions
^
[SQL: SELECT account_plugin_permissions.id AS account_plugin_permissions_id, account_plugin_permissions.tenant_id AS account_plugin_permissions_tenant_id, account_plugin_permissions.install_permission AS account_plugin_permissions_install_permission, account_plugin_permissions.debug_permission AS account_plugin_permissions_debug_permission
FROM account_plugin_permissions
WHERE account_plugin_permissions.tenant_id = %(tenant_id_1)s::UUID
LIMIT %(param_1)s]
[parameters: {'tenant_id_1': '190f9e50-1a48-4bee-8f9b-1e0393aa914e', 'param_1': 1}]
(Background on this error at: https://sqlalche.me/e/20/f405)`
✔️ Expected Behavior
I was expecting for either A) have the model configurations already set from the previous configuration, or B) to be able to install and configure plugins
❌ Actual Behavior
(see description above)
The error you're encountering, sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "account_plugin_permissions" does not exist, indicates that the account_plugin_permissions table is missing from your database. This is likely due to database migrations not being applied.
To resolve this issue, you need to manually apply the database migrations to ensure all necessary tables are created. Here are the steps you can follow:
-
Access your Docker environment: Open a terminal and navigate to your Docker environment.
-
Run the migration command: Execute the following command to apply all pending migrations:
docker exec docker-api-1 poetry run flask db upgrade
This command will apply the migrations and create the account_plugin_permissions table along with any other necessary tables [1][2].
If you continue to experience issues, ensure that the MIGRATION_ENABLED environment variable is set to true in your configuration, as this ensures migrations are executed automatically during application startup [3].
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
@dosu
After Execute the following command to apply all pending migrations;
docker exec docker-api-1 poetry run flask db upgrade
I got new bug, Here is the stack trace from the API:
`root@openai-test-10001-ecs:~# docker exec docker-api-1 poetry run flask db upgrade
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> 64b051264f32, init
Traceback (most recent call last):
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
self.dialect.do_execute(
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.DuplicateTable: relation "account_integrates" already exists
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/api/.venv/bin/flask", line 8, in <module>
sys.exit(main())
^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask/cli.py", line 1129, in main
cli.main()
File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1082, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 788, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask/cli.py", line 400, in decorator
return ctx.invoke(f, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 788, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/cli.py", line 154, in upgrade
_upgrade(directory, revision, sql, tag, x_arg)
File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 111, in wrapped
f(*args, **kwargs)
File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 200, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/app/api/.venv/lib/python3.12/site-packages/alembic/command.py", line 406, in upgrade
script.run_env()
File "/app/api/.venv/lib/python3.12/site-packages/alembic/script/base.py", line 586, in run_env
util.load_python_file(self.dir, "env.py")
File "/app/api/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
module = load_module_py(module_id, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/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 999, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/app/api/migrations/env.py", line 109, in <module>
run_migrations_online()
File "/app/api/migrations/env.py", line 103, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/app/api/.venv/lib/python3.12/site-packages/alembic/runtime/environment.py", line 946, in run_migrations
self.get_context().run_migrations(**kw)
File "/app/api/.venv/lib/python3.12/site-packages/alembic/runtime/migration.py", line 623, in run_migrations
step.migration_fn(**kw)
File "/app/api/migrations/versions/64b051264f32_init.py", line 23, in upgrade
op.create_table('account_integrates',
File "<string>", line 8, in create_table
File "<string>", line 3, in create_table
File "/app/api/.venv/lib/python3.12/site-packages/alembic/operations/ops.py", line 1318, in create_table
return operations.invoke(op)
^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/alembic/operations/base.py", line 442, in invoke
return fn(self, operation)
^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/alembic/operations/toimpl.py", line 143, in create_table
operations.impl.create_table(table, **kw)
File "/app/api/.venv/lib/python3.12/site-packages/alembic/ddl/impl.py", line 406, in create_table
self._exec(schema.CreateTable(table, **kw))
File "/app/api/.venv/lib/python3.12/site-packages/alembic/ddl/impl.py", line 247, in _exec
return conn.execute(construct, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1418, in execute
return meth(
^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/sql/ddl.py", line 180, in _execute_on_connection
return connection._execute_ddl(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1529, in _execute_ddl
ret = self._execute_context(
^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
return self._exec_single_context(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context
self._handle_dbapi_exception(
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2355, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
self.dialect.do_execute(
File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateTable) relation "account_integrates" already exists
[SQL:
CREATE TABLE account_integrates (
id UUID DEFAULT uuid_generate_v4() NOT NULL,
account_id UUID NOT NULL,
provider VARCHAR(16) NOT NULL,
open_id VARCHAR(255) NOT NULL,
encrypted_token VARCHAR(255) NOT NULL,
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP(0) NOT NULL,
updated_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP(0) NOT NULL,
CONSTRAINT account_integrate_pkey PRIMARY KEY (id),
CONSTRAINT unique_account_provider UNIQUE (account_id, provider),
CONSTRAINT unique_provider_open_id UNIQUE (provider, open_id)
)
]
(Background on this error at: https://sqlalche.me/e/20/f405)`
To resolve the psycopg2.errors.DuplicateTable: relation "account_integrates" already exists error, you can modify the migration script to check if the table already exists before attempting to create it. This can be done by adding a conditional check in the upgrade() function of your migration script. Here's an example of how you can adjust the script:
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";')
# Check if the table 'account_integrates' already exists
if not op.get_bind().dialect.has_table(op.get_bind(), 'account_integrates'):
op.create_table('account_integrates',
sa.Column('id', postgresql.UUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
sa.Column('account_id', postgresql.UUID(), nullable=False),
sa.Column('provider', sa.String(length=16), nullable=False),
sa.Column('open_id', sa.String(length=255), nullable=False),
sa.Column('encrypted_token', sa.String(length=255), nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP(0)'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP(0)'), nullable=False),
sa.PrimaryKeyConstraint('id', name='account_integrate_pkey'),
sa.UniqueConstraint('account_id', 'provider', name='unique_account_provider'),
sa.UniqueConstraint('provider', 'open_id', name='unique_provider_open_id')
)
# Continue with other table creations and operations
# ...
This modification ensures that the account_integrates table is only created if it does not already exist, preventing the DuplicateTable error [1].
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
要解决此错误,您可以修改迁移脚本,以便在尝试创建表之前检查该表是否已存在。这可以通过在迁移脚本的函数中添加条件检查来完成。下面是如何调整脚本的示例:
psycopg2.errors.DuplicateTable: relation "account_integrates" already exists``upgrade()def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp";')
# Check if the table 'account_integrates' already exists if not op.get_bind().dialect.has_table(op.get_bind(), 'account_integrates'): op.create_table('account_integrates', sa.Column('id', postgresql.UUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False), sa.Column('account_id', postgresql.UUID(), nullable=False), sa.Column('provider', sa.String(length=16), nullable=False), sa.Column('open_id', sa.String(length=255), nullable=False), sa.Column('encrypted_token', sa.String(length=255), nullable=False), sa.Column('created_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP(0)'), nullable=False), sa.Column('updated_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP(0)'), nullable=False), sa.PrimaryKeyConstraint('id', name='account_integrate_pkey'), sa.UniqueConstraint('account_id', 'provider', name='unique_account_provider'), sa.UniqueConstraint('provider', 'open_id', name='unique_provider_open_id') ) # Continue with other table creations and operations # ...此修改可确保仅在表不存在时创建表,从而防止错误
account_integrates``DuplicateTable[1].要继续与 Dosu 交谈,请提及 。
这个情况怎么办
INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade cf8f4fc45278 -> 11b07f66c737, remove unused tool_providers INFO [alembic.runtime.migration] Running upgrade 11b07f66c737 -> e1944c35e15e, add retry_index field to node-execution model Revision ID: e1944c35e15e Revises: 11b07f66c737 Create Date: 2024-12-20 06:28:30.287197 INFO [alembic.runtime.migration] Running upgrade e1944c35e15e -> d7999dfa4aae, remove workflow_node_executions.retry_index if exists INFO [alembic.runtime.migration] Running upgrade d7999dfa4aae -> e19037032219, parent-child-index INFO [alembic.runtime.migration] Running upgrade e19037032219 -> 923752d42eb6, add_auto_disabled_dataset_logs INFO [alembic.runtime.migration] Running upgrade 923752d42eb6 -> a91b476a53de, change workflow_runs.total_tokens to bigint Traceback (most recent call last): File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context self.dialect.do_execute( File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute cursor.execute(statement, parameters) psycopg2.errors.DataCorrupted: unexpected chunk number 10 (expected 0) for toast value 2668016 in pg_toast_17118
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/api/.venv/bin/flask", line 8, in
[SQL: ALTER TABLE workflow_runs ALTER COLUMN total_tokens TYPE BIGINT ] (Background on this error at: https://sqlalche.me/e/20/2j85)
执行以下命令以应用所有待处理的迁移后;
docker exec docker-api-1 poetry run flask db upgrade我遇到了新的错误,这是来自 API 的堆栈跟踪:
`root@openai-test-10001-ecs:~# docker exec docker-api-1 poetry run flask db upgrade INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade -> 64b051264f32, init Traceback (most recent call last): File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context self.dialect.do_execute( File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute cursor.execute(statement, parameters) psycopg2.errors.DuplicateTable: relation "account_integrates" already exists The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/api/.venv/bin/flask", line 8, in <module> sys.exit(main()) ^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask/cli.py", line 1129, in main cli.main() File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1082, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1697, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1697, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1443, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 788, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func return f(get_current_context(), *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask/cli.py", line 400, in decorator return ctx.invoke(f, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 788, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/cli.py", line 154, in upgrade _upgrade(directory, revision, sql, tag, x_arg) File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 111, in wrapped f(*args, **kwargs) File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 200, in upgrade command.upgrade(config, revision, sql=sql, tag=tag) File "/app/api/.venv/lib/python3.12/site-packages/alembic/command.py", line 406, in upgrade script.run_env() File "/app/api/.venv/lib/python3.12/site-packages/alembic/script/base.py", line 586, in run_env util.load_python_file(self.dir, "env.py") File "/app/api/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file module = load_module_py(module_id, path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/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 999, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "/app/api/migrations/env.py", line 109, in <module> run_migrations_online() File "/app/api/migrations/env.py", line 103, in run_migrations_online context.run_migrations() File "<string>", line 8, in run_migrations File "/app/api/.venv/lib/python3.12/site-packages/alembic/runtime/environment.py", line 946, in run_migrations self.get_context().run_migrations(**kw) File "/app/api/.venv/lib/python3.12/site-packages/alembic/runtime/migration.py", line 623, in run_migrations step.migration_fn(**kw) File "/app/api/migrations/versions/64b051264f32_init.py", line 23, in upgrade op.create_table('account_integrates', File "<string>", line 8, in create_table File "<string>", line 3, in create_table File "/app/api/.venv/lib/python3.12/site-packages/alembic/operations/ops.py", line 1318, in create_table return operations.invoke(op) ^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/alembic/operations/base.py", line 442, in invoke return fn(self, operation) ^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/alembic/operations/toimpl.py", line 143, in create_table operations.impl.create_table(table, **kw) File "/app/api/.venv/lib/python3.12/site-packages/alembic/ddl/impl.py", line 406, in create_table self._exec(schema.CreateTable(table, **kw)) File "/app/api/.venv/lib/python3.12/site-packages/alembic/ddl/impl.py", line 247, in _exec return conn.execute(construct, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1418, in execute return meth( ^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/sql/ddl.py", line 180, in _execute_on_connection return connection._execute_ddl( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1529, in _execute_ddl ret = self._execute_context( ^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context return self._exec_single_context( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context self._handle_dbapi_exception( File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2355, in _handle_dbapi_exception raise sqlalchemy_exception.with_traceback(exc_info[2]) from e File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context self.dialect.do_execute( File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 941, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateTable) relation "account_integrates" already exists [SQL: CREATE TABLE account_integrates ( id UUID DEFAULT uuid_generate_v4() NOT NULL, account_id UUID NOT NULL, provider VARCHAR(16) NOT NULL, open_id VARCHAR(255) NOT NULL, encrypted_token VARCHAR(255) NOT NULL, created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP(0) NOT NULL, updated_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP(0) NOT NULL, CONSTRAINT account_integrate_pkey PRIMARY KEY (id), CONSTRAINT unique_account_provider UNIQUE (account_id, provider), CONSTRAINT unique_provider_open_id UNIQUE (provider, open_id) ) ] (Background on this error at: https://sqlalche.me/e/20/f405)`
解决了吗