fix(migrations): eliminate duplicate SQL file loading #119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #118
Summary
Removes unnecessary
clear_cache()
calls that were causing SQL files to be loaded and parsed 3 times during a single migration operation.Root Cause
SQLFileLoader.clear_cache()
was being called before every migration operation, destroyingCoreSQLFileLoader
's internal cache (_files
,_queries
,_query_to_file
). This forced files to be re-parsed multiple times during a single migration run.Evidence from user logs:
Changes
clear_cache()
fromSQLFileLoader.get_up_sql()
clear_cache()
fromSQLFileLoader.get_down_sql()
clear_cache()
fromSQLFileLoader.validate_migration_file()
clear_cache()
fromSyncMigrationRunner.load_migration()
clear_cache()
fromAsyncMigrationRunner.load_migration()
Total: 5 lines deleted
Why This Works
CoreSQLFileLoader
already has proper caching built-in (seesqlspec/loader.py:428-429
):The cache clearing was unnecessary and counterproductive.
Impact
Testing
test_sql_loader_caches_files
to verify cache persistence across operationsBreaking Changes
None - internal optimization only.