Skip to content

chore: Replace 'db' with 'sa' for SQLAlchemy compatibility#35373

Merged
asukaminato0721 merged 4 commits intomainfrom
db-to-sa
Apr 19, 2026
Merged

chore: Replace 'db' with 'sa' for SQLAlchemy compatibility#35373
asukaminato0721 merged 4 commits intomainfrom
db-to-sa

Conversation

@asukaminato0721
Copy link
Copy Markdown
Contributor

@asukaminato0721 asukaminato0721 commented Apr 17, 2026

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Screenshots

Before After
... ...

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 added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 38.61% 38.61% 0.00%
Strict coverage 35.74% 35.74% 0.00%
Typed symbols 18,173 18,173 0
Untyped symbols 31,220 31,220 0
Modules 2516 2516 0

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.43%. Comparing base (3c7d673) to head (ec52eae).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #35373   +/-   ##
=======================================
  Coverage   85.43%   85.43%           
=======================================
  Files        4431     4431           
  Lines      206713   206714    +1     
  Branches    38470    38470           
=======================================
+ Hits       176612   176613    +1     
  Misses      26992    26992           
  Partials     3109     3109           
Flag Coverage Δ
api 84.78% <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 Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@asukaminato0721 asukaminato0721 marked this pull request as ready for review April 17, 2026 16:20
Copilot AI review requested due to automatic review settings April 17, 2026 16:20
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 17, 2026
@langgenius langgenius deleted a comment from github-actions bot Apr 17, 2026
@langgenius langgenius deleted a comment from github-actions bot Apr 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates workflow comment ORM models to use sqlalchemy as sa types/constructs instead of db.*, aligning these models with the broader SQLAlchemy-first patterns used across api/models.

Changes:

  • Introduce import sqlalchemy as sa in api/models/comment.py.
  • Replace db.* column/constraint/type usages with sa.* equivalents (e.g., PrimaryKeyConstraint, Text, DateTime, Boolean, text).
Comments suppressed due to low confidence (1)

api/models/comment.py:203

  • These FK columns still use db.ForeignKey(...) while this PR is replacing db.* constructs with sqlalchemy as sa. Consider switching both to sa.ForeignKey(...) (or sqlalchemy.ForeignKey) for consistency and to avoid coupling schema definitions to the Flask-SQLAlchemy db instance.
    comment_id: Mapped[str] = mapped_column(
        StringUUID, db.ForeignKey("workflow_comments.id", ondelete="CASCADE"), nullable=False
    )
    reply_id: Mapped[str | None] = mapped_column(
        StringUUID, db.ForeignKey("workflow_comment_replies.id", ondelete="CASCADE"), nullable=True
    )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread api/models/comment.py
Comment thread api/models/comment.py
@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 19, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 19, 2026
Merged via the queue into main with commit f8a4205 Apr 19, 2026
33 checks passed
@asukaminato0721 asukaminato0721 deleted the db-to-sa branch April 19, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants