Skip to content

Conversation

@pyramation
Copy link
Contributor

core(migrate): add toUnqualifiedLocal method for local tracking guard

Summary

Adds a private toUnqualifiedLocal method to the LaunchQLMigrate class that enforces local package scope for deployed/skipped change tracking. This centralizes logic that was previously duplicated in multiple locations and adds proper error handling for cross-package changes.

Key changes:

  • Added toUnqualifiedLocal private method that validates package scope and extracts local change names
  • Updated 3 locations in deploy and revert methods to use this centralized logic instead of inline splitting
  • Method throws an error when cross-package changes are encountered in local tracking arrays
  • Added test to verify functionality (though test couldn't be run due to Jest config issues)

Review & Testing Checklist for Human

This is a medium-risk change affecting critical deployment logic. Please verify:

  • Test the functionality manually - Run a deployment with mixed qualified/unqualified change names to ensure the method works correctly and deployed/skipped arrays only contain unqualified names
  • Validate error handling - Confirm that throwing errors on cross-package changes is the intended behavior and won't break legitimate existing workflows
  • Run the new test - Fix Jest configuration issues and ensure packages/core/__tests__/migrate/local-tracking-guard.test.ts passes and covers the right scenarios
  • Code logic review - Verify the string splitting logic in toUnqualifiedLocal handles all edge cases correctly (empty strings, multiple colons, etc.)

Notes

  • The test file was created but couldn't be executed during development due to Jest/TypeScript configuration issues
  • Minor import reordering occurred during development
  • This change was ported from stale PR devin/1756430832-local-tracking-guard to create a fresh implementation

Link to Devin run: https://app.devin.ai/sessions/93a117783417440999ebee209a464e9d
Requested by: Dan Lynch (@pyramation)

- Add private toUnqualifiedLocal method to LaunchQLMigrate class
- Enforces local package scope for deployed/skipped changes
- Throws error on cross-package changes to prevent silent bugs
- Update deploy and revert methods to use centralized logic
- Add test to verify functionality

Co-Authored-By: Dan Lynch <[email protected]>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 4 commits September 4, 2025 04:21
- Remove type annotations from mock function parameters
- Add password field to PgConfig object
- Use 'as any' type assertions for LaunchQLMigrate constructor and deploy method

Co-Authored-By: Dan Lynch <[email protected]>
… in local-tracking-guard test

- Replace MigrateTestFixture with jest.mock approach following tag-fallback.test.ts pattern
- Mock pg-cache and transaction utilities to avoid requiring PostgreSQL database
- Add direct test of toUnqualifiedLocal method for cross-package error handling
- Keep existing TypeScript type annotations for strict compilation
- Both test cases now pass without database dependencies

Co-Authored-By: Dan Lynch <[email protected]>
…cking

- Replace jest.mock approach with MigrateTestFixture for proper pg-env configuration
- Use fixture.setupTestDatabase() which calls getPgEnvOptions() for database config
- Follow established testing patterns from basic-deployment.test.ts
- Add proper beforeEach/afterEach hooks for setup and cleanup
- Both test cases now work with real PostgreSQL database via pg-env

Co-Authored-By: Dan Lynch <[email protected]>
@pyramation pyramation closed this Sep 16, 2025
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