Replies: 3 comments
-
|
I deleted the old model credentials, and now I can add new model credentials. |
Beta Was this translation helpful? Give feedback.
-
|
Your analysis is excellent and your SQL migration is correct and safe for a single-tenant instance. Here's confirmation on your three questions: 1. Is the SQL migration correct and safe? Yes. Your approach covers the same 5 tables and the same 3 value mappings that the official One difference: the official migration is more sophisticated — it groups rows by business key (e.g., 2. Are there other tables or JSON fields? Based on the official migration, these are the only 5 tables with 3. Will this conflict with the official migration later? No. The official migration is fully idempotent — it only selects rows where Multiple other users have applied similar SQL fixes successfully for this same issue [1] [2] [3]. Summary: Back up, run your SQL, verify with your verification query, and you're good. When you eventually upgrade to a version that includes PR #36520, the official migration will be a no-op since the values are already normalized. Written by @dosu, approved by crazywoola To reply, just mention @dosu. Docs are dead. Just use Dosu. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Self Checks
1. Is this request related to a challenge you're experiencing? Tell me about your story.
I upgraded Dify from v1.13.3 to v1.14.2 (self-hosted, Docker deployment), and the OpenAI-API-compatible plugin (v0.0.47 → v0.0.53) became partially unusable:
model_type Field required.It was frustrating because the plugin was working perfectly before the upgrade, and the errors gave no clear indication that the underlying cause was a
model_typecolumn value mismatch in the database.Root Cause
v1.14.0 refactored the
model_typecolumn from a free-form string toEnumText(ModelType)(a typed enum). The ORM layer (EnumTextinapi/models/types.py) transparently maps legacy values when reading, but writes and queries only use the new enum values:text-generationllmembeddingstext-embeddingrerankingrerankThis creates a read/write asymmetry:
process_result_value): Legacy values are correctly mapped viaModelType.value_of()fallback — this is why Chatflow still works.process_bind_param): Only new values are used —WHERE model_type = 'llm'does not match rows storing'text-generation'. This is why the console cannot find or manage old credentials.Additionally, the
tenant_default_modelstable has a unique constraint on(tenant_id, model_type). After the upgrade, both legacy and canonical rows can coexist (since'text-generation'≠'llm'at the DB level), creating logical duplicates that violate the application's expectations.Affected Tables
5 tables store
model_typeand are affected:provider_model_credentialsprovider_modelsprovider_model_settingsload_balancing_model_configstenant_default_modelsOfficial Migration Not Available in v1.14.2
The official migration command
flask data-migrate legacy-model-typeswas introduced in PR #36520 (merged May 27), which is after the v1.14.2 release (May 19). So v1.14.2 does not include this command.2. Additional context or comments
Proposed Fix — Manual SQL Migration
I'd like to confirm whether the following manual SQL migration is safe and correct for fixing this issue. It has been verified on a self-hosted single-tenant instance. I've already backed up the affected tables before proceeding.
Pre-check: Verify
provider_modelsHas No Unique Constraint Conflictsprovider_modelsalso needs the two-step approach (DELETE conflicting rows first, then UPDATE).Migration SQL
Key design decisions:
UPDATEis safe because they have no unique constraint involvingmodel_typealone.tenant_default_models): Requires a two-step approach due to theunique_tenant_default_model_typeconstraint on(tenant_id, model_type). Step A deletes legacy rows that have a corresponding canonical row (keeping the canonical row). Step B updates remaining legacy rows that have no canonical counterpart.BEGIN/COMMIT) for atomicity.Verification Query
Expected result: No
text-generation,embeddings, orrerankingvalues should remain.Questions for the Community / Maintainers
flask data-migrate legacy-model-typescommand does internally?model_typevalues that we need to handle?Relevant Commits / PRs
flask data-migrate legacy-model-types(not included in v1.14.2)Environment
Beta Was this translation helpful? Give feedback.
All reactions