Skip to content

chore(models): remove redundant server_default from oauth, source, onboarding and comment models - #42520

Open
CodeTrainerMan wants to merge 1 commit into
langgenius:mainfrom
CodeTrainerMan:chore/remove-redundant-server-default-oauth-source
Open

CodeTrainerMan wants to merge 1 commit into
langgenius:mainfrom
CodeTrainerMan:chore/remove-redundant-server-default-oauth-source

Conversation

@CodeTrainerMan

Copy link
Copy Markdown
Contributor

Summary

Part of #29314

Second slice of the redundant server_default cleanup, following #42519 (trigger.py) and the same pattern as #39886. As described in the issue, server_default only affects migration generation and is never applied while the application runs, so keeping both it and an equivalent application-level default= on the same column is confusing - especially since new models are usually written by copying existing ones.

Model Column Removed server_default Kept application-level default
DatasourceProvider (oauth.py) is_default sa.false() False
DatasourceProvider (oauth.py) expires_at "-1" -1
DatasourceProvider (oauth.py) visibility sa.text("'all_team_members'") PermissionEnum.ALL_TEAM (== "all_team_members")
DataSourceOauthBinding (source.py) disabled sa.false() False
DataSourceApiKeyAuthBinding (source.py) disabled sa.false() False
AccountStepByStepTourState (onboarding.py) skipped sa.false() False
WorkflowComment (comment.py) resolved sa.false() False

Worth calling out: DatasourceProvider.expires_at is an sa.Integer column whose server_default was the string "-1" rather than the integer -1, so it did not even match the application-level default=-1 it duplicated. Removing it leaves a single, type-correct source of truth.

The remaining server_default=func.current_timestamp() / func.now() entries on created_at / updated_at are untouched: they have no application-level default, so removing them would change insert behavior. That decision was already discussed in the issue.

Scope: these four files only. Other model files are untouched to avoid overlapping with the in-flight PRs #39886 (agent.py, credential_permission.py) and #41391 (skill.py).

Verified locally: ruff check and ruff format --diff on all four files are clean (ruff 0.16.6, the version pinned in api/pyproject.toml), and python -m py_compile passes. make type-check (pyrefly) was not run locally because the optional vdb dependencies cannot be built in this Windows environment; CI covers it.

Screenshots

Before After
N/A - backend only, no UI change N/A - backend only, no UI change

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint; make type-check (backend) and vp staged (frontend) to appease the lint gods

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 64.78% 64.78% -0.00%
Strict coverage 64.39% 64.39% -0.00%
Typed symbols 46,835 46,834 -1
Untyped symbols 25,614 25,615 +1
Modules 3410 3410 0

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.53%. Comparing base (f12a876) to head (a2534b5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #42520      +/-   ##
==========================================
- Coverage   87.53%   87.53%   -0.01%     
==========================================
  Files        5468     5468              
  Lines      316733   316733              
  Branches    63517    63517              
==========================================
- Hits       277265   277261       -4     
- Misses      34098    34103       +5     
+ Partials     5370     5369       -1     
Flag Coverage Δ
api 87.18% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant