-
Notifications
You must be signed in to change notification settings - Fork 19.9k
Open
Labels
🐞 bugSomething isn't workingSomething isn't working
Description
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
v1.11.4
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
- Deploy Dify using MySQL as the database (Docker / docker-compose).
- Initialize the database.
- Run
flask db upgrade. - Migration
7df29de0f6be_add_credit_poolfails when creating tabletenant_credit_pools.
When using MySQL as the database backend, the migration for tenant_credit_pools fails due to a PostgreSQL-specific default value.
The migration and model definition use:
server_default = uuid_generate_v4()
However, uuid_generate_v4() is a PostgreSQL-only function and is not supported by MySQL, which causes the following error during migration:
File "/app/api/.venv/lib/python3.12/site-packages/pymysql/connections.py", line 1203, in read
first_packet = self.connection._read_packet()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/pymysql/connections.py", line 782, in _read_packet
packet.raise_for_error()
File "/app/api/.venv/lib/python3.12/site-packages/pymysql/protocol.py", line 219, in raise_for_error
err.raise_mysql_exception(self._data)
File "/app/api/.venv/lib/python3.12/site-packages/pymysql/err.py", line 150, in raise_mysql_exception
raise errorclass(errno, errval)
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (3770, "Default value expression of column 'id' contains a disallowed function: `uuid_generate_v4`.")
[SQL:
CREATE TABLE tenant_credit_pools (
id CHAR(36) NOT NULL DEFAULT (uuid_generate_v4()),
tenant_id CHAR(36) NOT NULL,
pool_type VARCHAR(40) NOT NULL DEFAULT 'trial',
quota_limit BIGINT NOT NULL,
quota_used BIGINT NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT tenant_credit_pool_pkey PRIMARY KEY (id)
)
]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
This makes a fresh MySQL installation fail during flask db upgrade.
✔️ Expected Behavior
Migrations should work correctly on MySQL without requiring PostgreSQL-specific functions.
UUIDs should be generated at the application level for MySQL deployments.
❌ Actual Behavior
The migration fails with a MySQL error because uuid_generate_v4() is used as a server-side default.
dosubot and lakako
Metadata
Metadata
Assignees
Labels
🐞 bugSomething isn't workingSomething isn't working