[Chore/Refactor] Remove server_default in model definitions #20878

Open
opened 2026-02-21 20:09:38 -05:00 by yindo · 3 comments
Owner

Originally created by @QuantumGhost on GitHub (Dec 8, 2025).

Originally assigned to: @AkhmetovOlzhass on GitHub.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for refactoring, 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.

Description

Summary

PR #28188 introduced MySQL support and adjusted migration accordingly. However, the model definition is not adjusted, and most models still contains the server_default=sa.text('uuid_generate_v4()') option. While the server_default argument is only used to generate migration and not applied while running application, it still causes confusion, especially for new model definitions, as implementors of new models (both real humans and AIs) generally references existing model definitions as examples.

Solution

Remove the server_default parameter from UUID column definitions in model files, allowing the application layer to handle database-specific UUID generation by setting the default=uuid.uuid4 option for those models.

Motivation

No response

Additional Context

No response

Originally created by @QuantumGhost on GitHub (Dec 8, 2025). Originally assigned to: @AkhmetovOlzhass on GitHub. ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for refactoring, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Description ## Summary PR #28188 introduced MySQL support and adjusted migration accordingly. However, the model definition is not adjusted, and most models still contains the `server_default=sa.text('uuid_generate_v4()')` option. While the `server_default` argument is only used to generate migration and not applied while running application, it still causes confusion, especially for new model definitions, as implementors of new models (both real humans and AIs) generally references existing model definitions as examples. ## Solution Remove the `server_default` parameter from UUID column definitions in model files, allowing the application layer to handle database-specific UUID generation by setting the `default=uuid.uuid4` option for those models. ### Motivation _No response_ ### Additional Context _No response_
yindo added the good first issuerefactor labels 2026-02-21 20:09:38 -05:00
Author
Owner

@AkhmetovOlzhass commented on GitHub (Dec 9, 2025):

Hi! I'd like to take this issue

@AkhmetovOlzhass commented on GitHub (Dec 9, 2025): Hi! I'd like to take this issue
Author
Owner

@tysoncung commented on GitHub (Dec 11, 2025):

I'm interested in working on this issue. Could you provide more context about what you're looking for? Any additional details about requirements or constraints would be helpful.

@tysoncung commented on GitHub (Dec 11, 2025): I'm interested in working on this issue. Could you provide more context about what you're looking for? Any additional details about requirements or constraints would be helpful.
Author
Owner

@AkhmetovOlzhass commented on GitHub (Dec 17, 2025):

I searched through all SQLAlchemy ORM models and confirmed that
all UUID primary keys are generated at the application level
(uuid4 / uuidv7).

The only occurrences of uuid_generate_v4() are in historical Alembic
migration files, not in runtime models.

No changes are required. This issue appears to be already resolved

@AkhmetovOlzhass commented on GitHub (Dec 17, 2025): I searched through all SQLAlchemy ORM models and confirmed that all UUID primary keys are generated at the application level (uuid4 / uuidv7). The only occurrences of uuid_generate_v4() are in historical Alembic migration files, not in runtime models. No changes are required. This issue appears to be already resolved
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20878