Skip to content

chore(api): fix Alembic offline migration compatibility - #24795

Merged
QuantumGhost merged 3 commits into
langgenius:mainfrom
QuantumGhost:chore/fix-alembic-offline-mode
Aug 29, 2025
Merged

QuantumGhost merged 3 commits into
langgenius:mainfrom
QuantumGhost:chore/fix-alembic-offline-mode

Conversation

@QuantumGhost

Copy link
Copy Markdown
Contributor

Summary

This PR fixes Alembic offline mode (--sql flag) by ensuring data migration functions only execute in online mode. When running in offline mode, these functions now skip data operations and output informational comments to the generated SQL.

Fixes #24794.

Screenshots

N/A

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 dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes Alembic offline migration compatibility by preventing data migration functions from executing when running in offline mode (--sql flag). Instead of attempting database operations that would fail in offline mode, the migrations now output informational SQL comments instructing users to manually run the data migration functions.

  • Added offline mode detection using context.is_offline_mode() to skip data migrations
  • Added informational SQL comments in offline mode to guide manual data migration
  • Added CI test to verify offline migration compatibility for both upgrade and downgrade operations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
api/migrations/versions/2025_08_13_1605-0e154742a5fa_add_provider_model_multi_credential.py Added offline mode checks and informational comments for data migration functions
api/migrations/versions/2025_08_09_1553-e8446f481c1e_add_provider_credential_pool_support.py Added offline mode checks and informational comments for data migration functions
.github/workflows/db-migration-test.yml Added CI test to verify offline migration compatibility

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@QuantumGhost
QuantumGhost marked this pull request as ready for review August 29, 2025 10:28
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 29, 2025
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 29, 2025
@QuantumGhost
QuantumGhost merged commit 8d60e5c into langgenius:main Aug 29, 2025
8 checks passed
Cluas pushed a commit to Cluas/dify that referenced this pull request Sep 1, 2025
…4795)

This PR fixes Alembic offline mode (`--sql` flag) by ensuring data migration functions only execute in online mode. When running in offline mode, these functions now skip data operations and output informational comments to the generated SQL.
Ssazurov pushed a commit to Ssazurov/dify that referenced this pull request Aug 8, 2026
…4795)

This PR fixes Alembic offline mode (`--sql` flag) by ensuring data migration functions only execute in online mode. When running in offline mode, these functions now skip data operations and output informational comments to the generated SQL.
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.

Alembic Offline Mode Fails Due to Data Migration Functions

3 participants