Skip to content

fix(migrations): resolve extension SQL query names - #686

Merged
cofin merged 1 commit into
mainfrom
fix/bug-bash-1
Aug 7, 2026
Merged

fix(migrations): resolve extension SQL query names#686
cofin merged 1 commit into
mainfrom
fix/bug-bash-1

Conversation

@cofin

@cofin cofin commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

  • isolate SQL query loaders for each registered extension migration directory
  • preserve raw filename-local query directives while retaining extension-prefixed tracker and bulk-loading identities
  • document both supported extension migration layouts and add synchronous, asynchronous, collision, and integration regressions

Root cause

Extension migration discovery prefixes versions for tracking, but SQL query names are derived from the raw migration filename. The runners checked the shared loader using the prefixed tracker version, so valid extension-directory SQL migrations appeared to have no upgrade query. Reusing one shared loader also caused collisions when multiple extensions shipped the same numeric version.

Impact

Third-party extensions can now ship ordinary SQL migrations such as 0001_create_table.sql with migrate-0001-up and migrate-0001-down. SQLSpec still records those migrations as ext_<extension>_0001, and existing main-directory prefixed migrations remain unchanged.

@codecov-commenter

codecov-commenter commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.24390% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.36%. Comparing base (7bf79bb) to head (ab5b7ba).

Files with missing lines Patch % Lines
sqlspec/migrations/runner.py 90.24% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #686      +/-   ##
==========================================
+ Coverage   77.34%   77.36%   +0.01%     
==========================================
  Files         476      476              
  Lines       68160    68193      +33     
  Branches     9376     9385       +9     
==========================================
+ Hits        52720    52758      +38     
+ Misses      12032    12026       -6     
- Partials     3408     3409       +1     
Flag Coverage Δ
integration 60.88% <56.09%> (-0.02%) ⬇️
py3.10 75.68% <90.24%> (+0.01%) ⬆️
py3.11 75.69% <90.24%> (+11.06%) ⬆️
py3.12 75.68% <90.24%> (+<0.01%) ⬆️
py3.13 75.69% <90.24%> (+<0.01%) ⬆️
py3.14 76.57% <90.24%> (+0.02%) ⬆️
unit 64.94% <85.36%> (+0.02%) ⬆️

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

Files with missing lines Coverage Δ
sqlspec/migrations/runner.py 85.58% <90.24%> (+0.32%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cofin
cofin marked this pull request as ready for review August 7, 2026 01:11
@cofin
cofin merged commit 949eb9d into main Aug 7, 2026
36 of 39 checks passed
@cofin
cofin deleted the fix/bug-bash-1 branch August 7, 2026 02:19
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.

2 participants