Skip to content

docker downgrade from v2.0.0-beta.2 to 1.9.0 faild #26091

Closed as not planned
Closed as not planned

Description

@Riding-A-Colt

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.9.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

use docker downgrade from v2.0.0-beta.2 to 1.9.0 fialed

2025-09-23 11:30:00 /bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
2025-09-23 11:30:00 /entrypoint.sh: line 7: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
2025-09-23 11:30:23 INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
2025-09-23 11:30:23 INFO [alembic.runtime.migration] Will assume transactional DDL.
2025-09-23 11:30:23 ERROR [flask_migrate] Error: Can't locate revision identified by 'b45e25c2d166'

I try to execute these command but the the docker-api-1 failed and restart:
uv run flask db downgrade cf7c38a32b2d
uv run flask db upgrade
uv run flask transform-datasource-credentials

then i add sleeep command and execute these commands but still the same faild

        services:
          api:
            image: langgenius/dify-api:1.9.0
            restart: always
            command: sleep infinity
           .....

$ uv run flask db downgrade cf7c38a32b2d
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
ERROR [flask_migrate] Error: Can't locate revision identified by 'b45e25c2d166'

✔️ Expected Behavior

migrate properly

❌ Actual Behavior

migrate failed

Activity

  1. dosubot commented on Sep 23, 2025

    @dosubot

    Hi @Riding-A-Colt! I'm Dosu and I’m helping the dify team.

    Downgrading Dify from v2.0.0-beta.2 to 1.9.0 fails because the database contains Alembic migration revisions (like b45e25c2d166) that do not exist in the 1.9.0 codebase. This happens because newer versions add migrations that older versions can't recognize, so Alembic can't find the revision and the migration fails.

    To work around this, you can manually fix the database version conflict by stopping Dify, exposing the PostgreSQL port, connecting to the database, and deleting the problematic revision record from the alembic_version table. After that, restart Dify and the migration should proceed. Always back up your database before making changes. Here’s a step-by-step guide:

    1. Stop Dify:
      docker compose down
    2. Expose PostgreSQL port in your docker-compose.yaml (e.g., 5432:5432).
    3. Restart Dify:
      docker compose up -d
    4. Connect to your database (default: user postgres, password difyai123456).
    5. In the database, go to dify -> public -> alembic_version and delete the row with the problematic revision (b45e25c2d166).
    6. Restart Dify again.

    Manual downgrades are risky and may require further schema changes, so always test on a backup or staging environment first. More details and community solutions are discussed here.

    If automatic migration still fails, you may need to manually execute SQL statements from migration files directly in the database. After any manual fix, restart your containers with docker compose down and docker compose up -d as recommended here.

    Downgrades are not officially supported and may require significant manual work. Always back up your data before attempting!

    To reply, just mention @dosu.


    How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

  2. added
    🐞 bug
    on Sep 23, 2025
  3. crazywoola commented on Sep 23, 2025

    @crazywoola
    Member

    Try to run uv run flask db downgrade and uv run flask db upgrade in the container.

  4. Tabll commented on Sep 24, 2025

    @Tabll

    downgrade encountered the same issue, so it's better to stay on 2.0.0-beta.2 for now.

    Additionally, what is the relationship between 1.9.0 and 2.0.0-beta.2? Will there be a direct upgrade path from 2.0.0-beta.2 to future 2.x versions?

  5. pinned this issue on Sep 24, 2025
  6. JohnJyong commented on Sep 24, 2025

    @JohnJyong
    Contributor

    thanks for your feedback. If you want to upgrade Dify‘s version form 2.0.0-beta.2 to 1.9.0, you need downgrade your db migration to cf7c38a32b2d in the 2.0.0-beta.2 envrionment, then you can update your version to 1.9.0 @Riding-A-Colt

  7. JohnJyong commented on Sep 24, 2025

    @JohnJyong
    Contributor
    Image
  8. Riding-A-Colt commented on Sep 24, 2025

    @Riding-A-Colt
    Author

    thanks for your feedback. If you want to upgrade Dify‘s version form 2.0.0-beta.2 to 1.9.0, you need downgrade your db migration to cf7c38a32b2d in the 2.0.0-beta.2 envrionment, then you can update your version to 1.9.0 @Riding-A-Colt

    I checkout back to 2.0.0-beta.2 and execute uv run flask db downgrade cf7c38a32b2d in the docker-api-1 container but did't work:

    INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
    INFO [alembic.runtime.migration] Will assume transactional DDL.
    ERROR [flask_migrate] Error: Can't locate revision identified by 'cf7c38a32b2d'

  9. xuesd commented on Sep 24, 2025

    @xuesd

    The same issue occurred when downgrading from 2.0.0-beta. 2 to 1.8.0, and now upgrading to 1.9.0. I also executed the 'docker exec it docker-api-1 UV run Flask transform datasource credentials' command, but still encountered errors

  10. nariba commented on Sep 24, 2025

    @nariba

    I've been pulling git frequently over the past few days, and I started seeing the same error.

    It seems a fix was included in the past few days to revert the 2.0.0-beta2 version back to 1.9.0.
    This appears to have caused this issue due to a series of compatibility problems.

    I don't understand why you'd want to downgrade to 1.9.0, but if you just want Dify to work in 2.0.0-beta2, you might try temporarily reverting the following commit.

    commit 24e8d21
    Author: QuantumGhost obelisk.reg+git@gmail.com
    Date: Mon Sep 22 19:14:43 2025 +0800

    chore(api): bump version (#25917)
    
  11. efreykongcn commented on Sep 25, 2025

    @efreykongcn
    Contributor

    I encountered the same problem. The root cause is that cf7c38a32b2d belongs to the 1.9.0 migration branch, so it cannot be reached directly from 2.0.0-beta.2. b95962a3885c is the common parent revision of both 1.9.0 and 2.0.0-beta.2.

    Following these steps, I successfully downgraded to 1.9.0 while keeping the app, plugins, and other data intact. Backup your Dify database before attempting this.

    Steps

    1. Checkout 2.0.0-beta.2:
    git checkout 2.0.0-beta.2
    cd api
    1. Modify migration files to handle PostgreSQL constraints and UUID conversions:

      • Add NOT NULL column with default
      • Use postgresql_using for UUID conversions

    2. Execute downgrade to the common parent revision:

    uv run flask db downgrade b95962a3885c

    1. Restore changes:

    git restore .

    1. Checkout 1.9.0 and adjust necessary migrations (if needed), then upgrade:
    git checkout 1.9.0
    
    
    uv run flask db upgrade
    uv run flask transform-datasource-credentials
    docker compose down
    docker compose up -d

    Notes / Tips:
    • Columns with type changes (e.g., plugin_id to UUID) require postgresql_using to avoid conversion errors.
    • Adding NOT NULL columns to existing tables requires either a default value or a two-step process (nullable → populate → set NOT NULL).
    • Using the common ancestor revision (b95962a3885c) ensures the downgrade path is valid without breaking Alembic’s migration chain.

    This approach preserves all existing app data and avoids full database rebuilds.

  12. koking0 commented on Sep 25, 2025

    @koking0

    encounter error:

    # uv run flask db downgrade b95962a3885c
    INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
    INFO  [alembic.runtime.migration] Will assume transactional DDL.
    INFO  [alembic.runtime.migration] Running downgrade 76db8b6ed8f1 -> 8c5088481127, add WorkflowDraftVariableFile
    INFO  [alembic.runtime.migration] Running downgrade 8c5088481127 -> 17d4db47800c, add_pipeline_info_17
    INFO  [alembic.runtime.migration] Running downgrade 17d4db47800c -> 74e5f667f4b7, datasource_oauth_refresh
    INFO  [alembic.runtime.migration] Running downgrade 74e5f667f4b7 -> d3c68680d3ba, add_pipeline_info_15
    INFO  [alembic.runtime.migration] Running downgrade d3c68680d3ba -> fcb46171d891, add_pipeline_info_14
    INFO  [alembic.runtime.migration] Running downgrade fcb46171d891 -> 2008609cf2bb, add_pipeline_info_13
    INFO  [alembic.runtime.migration] Running downgrade 2008609cf2bb -> 1bce102aef9a, add_pipeline_info_12
    INFO  [alembic.runtime.migration] Running downgrade 1bce102aef9a -> d4a76fde2724, datasource_oauth_2
    INFO  [alembic.runtime.migration] Running downgrade d4a76fde2724 -> 15e40b74a6d2, datasource_oauth_1
    Traceback (most recent call last):
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1963, in _exec_single_context
        self.dialect.do_execute(
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 943, in do_execute
        cursor.execute(statement, parameters)
    psycopg2.errors.DatatypeMismatch: column "plugin_id" cannot be cast automatically to type uuid
    HINT:  You might need to specify "USING plugin_id::uuid".
    
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/app/api/.venv/bin/flask", line 10, in <module>
        sys.exit(main())
                 ^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/flask/cli.py", line 1131, in main
        cli.main()
      File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1363, in main
        rv = self.invoke(ctx)
             ^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1830, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1830, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1226, in invoke
        return ctx.invoke(self.callback, **ctx.params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 794, in invoke
        return callback(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/click/decorators.py", line 34, 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 794, in invoke
        return callback(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/cli.py", line 172, in downgrade
        _downgrade(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 210, in downgrade
        command.downgrade(config, revision, sql=sql, tag=tag)
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/command.py", line 530, in downgrade
        script.run_env()
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/script/base.py", line 551, 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 116, 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 136, 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 627, in run_migrations
        step.migration_fn(**kw)
      File "/app/api/migrations/versions/2025_07_18_1409-d4a76fde2724_add_pipeline_info_10.py", line 45, in downgrade
        with op.batch_alter_table('datasource_oauth_params', schema=None) as batch_op:
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.12/contextlib.py", line 144, in __exit__
        next(self.gen)
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/operations/base.py", line 397, in batch_alter_table
        impl.flush()
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/operations/batch.py", line 115, in flush
        fn(*arg, **kw)
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/ddl/postgresql.py", line 179, in alter_column
        self._exec(
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/ddl/impl.py", line 246, in _exec
        return conn.execute(construct, params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1415, in execute
        return meth(
               ^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/sql/ddl.py", line 187, in _execute_on_connection
        return connection._execute_ddl(
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1526, in _execute_ddl
        ret = self._execute_context(
              ^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1842, in _execute_context
        return self._exec_single_context(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1982, in _exec_single_context
        self._handle_dbapi_exception(
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2351, 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 1963, in _exec_single_context
        self.dialect.do_execute(
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 943, in do_execute
        cursor.execute(statement, parameters)
    sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DatatypeMismatch) column "plugin_id" cannot be cast automatically to type uuid
    HINT:  You might need to specify "USING plugin_id::uuid".
    
    [SQL: ALTER TABLE datasource_oauth_params ALTER COLUMN plugin_id TYPE UUID ]
    (Background on this error at: https://sqlalche.me/e/20/f405)
    
  13. efreykongcn commented on Sep 25, 2025

    @efreykongcn
    Contributor

    Step 2. Modify migration files to handle PostgreSQL constraints and UUID conversions:

    •	/dify/api/migrations/versions/2025_05_16_1659-abb18a379e62_add_pipeline_info_2.py
    
    def downgrade():
        # ### commands auto generated by Alembic - please adjust! ###
        with op.batch_alter_table('pipelines', schema=None) as batch_op:
            batch_op.add_column(
                sa.Column(
                    'mode', 
                    sa.VARCHAR(length=255), 
                    autoincrement=False, 
                    nullable=False, 
                    server_default='default'
                )
            )
    •	/dify/api/migrations/versions/2025_05_30_0052-e4fb49a4fe86_add_pipeline_info_4.py
    
    def downgrade():
        # ### commands auto generated by Alembic - please adjust! ###
        with op.batch_alter_table('datasource_providers', schema=None) as batch_op:
            batch_op.alter_column(
                'plugin_id',
                existing_type=sa.TEXT(),
                type_=sa.UUID(),
                existing_nullable=False,
                postgresql_using='plugin_id::uuid'
            )
    •	/dify/api/migrations/versions/2025_07_18_1409-d4a76fde2724_add_pipeline_info_10.py
    
    with op.batch_alter_table('datasource_oauth_params', schema=None) as batch_op:
        batch_op.alter_column(
            'plugin_id',
            existing_type=sa.String(length=255),
            type_=sa.UUID(),
            existing_nullable=False,
            postgresql_using='plugin_id::uuid'
        )

    Step 5. Checkout the 1.9.0 branch and modify the following migration file:
    git checkout 1.9.0

    •	/dify/api/migrations/versions/2025_09_17_1515-68519ad5cd18_knowledge_pipeline_migrate.py
    
    with op.batch_alter_table('workflow_draft_variables', schema=None) as batch_op:
        batch_op.add_column(
            sa.Column(
                'file_id', 
                models.types.StringUUID(), 
                nullable=True, 
                comment='Reference to WorkflowDraftVariableFile if variable is offloaded to external storage'
            )
        )
        """ batch_op.add_column(
            sa.Column(
                'is_default_value', 
                sa.Boolean(), 
                nullable=False,
                server_default=sa.text(text="FALSE"),
                comment='Indicates whether the current value is the default for a conversation variable. Always `FALSE` for other types of variables.',
            )
        ) """
        batch_op.create_index('workflow_draft_variable_file_id_idx', ['file_id'], unique=False)

    then, execute the rest upgrade command (uv run flask db upgrade etc.)

    @koking0

  14. koking0 commented on Sep 25, 2025

    @koking0

    @efreykongcn new bee!

  15. unpinned this issue on Sep 29, 2025
  16. Tabll commented on Oct 9, 2025

    @Tabll

    @efreykongcn really NEW BEE!following your steps, i successfully downgraded from v2.0.0-beta.2 to 1.9.1 without any errors or warnings!
    Thank you so much!

  17. doonygit commented on Jan 16, 2026

    @doonygit

    encounter error:

    # uv run flask db downgrade b95962a3885c
    INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
    INFO  [alembic.runtime.migration] Will assume transactional DDL.
    INFO  [alembic.runtime.migration] Running downgrade 76db8b6ed8f1 -> 8c5088481127, add WorkflowDraftVariableFile
    INFO  [alembic.runtime.migration] Running downgrade 8c5088481127 -> 17d4db47800c, add_pipeline_info_17
    INFO  [alembic.runtime.migration] Running downgrade 17d4db47800c -> 74e5f667f4b7, datasource_oauth_refresh
    INFO  [alembic.runtime.migration] Running downgrade 74e5f667f4b7 -> d3c68680d3ba, add_pipeline_info_15
    INFO  [alembic.runtime.migration] Running downgrade d3c68680d3ba -> fcb46171d891, add_pipeline_info_14
    INFO  [alembic.runtime.migration] Running downgrade fcb46171d891 -> 2008609cf2bb, add_pipeline_info_13
    INFO  [alembic.runtime.migration] Running downgrade 2008609cf2bb -> 1bce102aef9a, add_pipeline_info_12
    INFO  [alembic.runtime.migration] Running downgrade 1bce102aef9a -> d4a76fde2724, datasource_oauth_2
    INFO  [alembic.runtime.migration] Running downgrade d4a76fde2724 -> 15e40b74a6d2, datasource_oauth_1
    Traceback (most recent call last):
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1963, in _exec_single_context
        self.dialect.do_execute(
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 943, in do_execute
        cursor.execute(statement, parameters)
    psycopg2.errors.DatatypeMismatch: column "plugin_id" cannot be cast automatically to type uuid
    HINT:  You might need to specify "USING plugin_id::uuid".
    
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/app/api/.venv/bin/flask", line 10, in <module>
        sys.exit(main())
                 ^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/flask/cli.py", line 1131, in main
        cli.main()
      File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1363, in main
        rv = self.invoke(ctx)
             ^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1830, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1830, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 1226, in invoke
        return ctx.invoke(self.callback, **ctx.params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/click/core.py", line 794, in invoke
        return callback(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/click/decorators.py", line 34, 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 794, in invoke
        return callback(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/flask_migrate/cli.py", line 172, in downgrade
        _downgrade(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 210, in downgrade
        command.downgrade(config, revision, sql=sql, tag=tag)
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/command.py", line 530, in downgrade
        script.run_env()
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/script/base.py", line 551, 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 116, 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 136, 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 627, in run_migrations
        step.migration_fn(**kw)
      File "/app/api/migrations/versions/2025_07_18_1409-d4a76fde2724_add_pipeline_info_10.py", line 45, in downgrade
        with op.batch_alter_table('datasource_oauth_params', schema=None) as batch_op:
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.12/contextlib.py", line 144, in __exit__
        next(self.gen)
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/operations/base.py", line 397, in batch_alter_table
        impl.flush()
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/operations/batch.py", line 115, in flush
        fn(*arg, **kw)
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/ddl/postgresql.py", line 179, in alter_column
        self._exec(
      File "/app/api/.venv/lib/python3.12/site-packages/alembic/ddl/impl.py", line 246, in _exec
        return conn.execute(construct, params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1415, in execute
        return meth(
               ^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/sql/ddl.py", line 187, in _execute_on_connection
        return connection._execute_ddl(
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1526, in _execute_ddl
        ret = self._execute_context(
              ^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1842, in _execute_context
        return self._exec_single_context(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1982, in _exec_single_context
        self._handle_dbapi_exception(
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2351, 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 1963, in _exec_single_context
        self.dialect.do_execute(
      File "/app/api/.venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 943, in do_execute
        cursor.execute(statement, parameters)
    sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DatatypeMismatch) column "plugin_id" cannot be cast automatically to type uuid
    HINT:  You might need to specify "USING plugin_id::uuid".
    
    [SQL: ALTER TABLE datasource_oauth_params ALTER COLUMN plugin_id TYPE UUID ]
    (Background on this error at: https://sqlalche.me/e/20/f405)
    

    I got zhe same err,how do it?

  18. doonygit commented on Jan 16, 2026

    @doonygit

    I get it .
    because in api container,the file in migrations\versions is old,should cp the modify file into api container 。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions