Skip to content

Conversation

@pyramation
Copy link
Contributor

feat(pgpm): add --clobber flag for export command

Summary

This PR changes the pgpm export command to be non-destructive by default. Previously, exporting to an existing module would silently delete and recreate the deploy/, revert/, and verify/ directories. Now it throws an error unless the --clobber flag is explicitly provided.

Key changes:

  • Added clobber option to ExportOptions, ExportMigrationsToDiskOptions, and PreparePackageOptions interfaces
  • Updated preparePackage to throw a descriptive error when module exists and clobber=false
  • Added --clobber CLI flag to pgpm export command with help text

Review & Testing Checklist for Human

  • Breaking change awareness: This changes default behavior - existing scripts that rely on pgpm export overwriting modules will now fail. Verify this is the intended behavior.
  • Test the error path: Run pgpm export targeting an existing module without --clobber and verify the error message is clear
  • Test the clobber path: Run pgpm export --clobber on an existing module and verify it overwrites correctly
  • Verify both packages are protected: The export creates two packages (database dump and services) - both should be protected by this check

Recommended test plan:

  1. Create a test workspace with pgpm init workspace
  2. Run pgpm export to create initial modules
  3. Run pgpm export again without --clobber → should error
  4. Run pgpm export --clobber → should succeed and overwrite

Notes

No unit tests were added for this new functionality - the existing test suite doesn't have database connectivity in CI to test the full export flow.

Link to Devin run: https://app.devin.ai/sessions/7e7813472a0643aa88ccb509b288050a
Requested by: Dan Lynch ([email protected]) @pyramation

- Add clobber option to ExportOptions, ExportMigrationsToDiskOptions, and PreparePackageOptions interfaces
- Update preparePackage to throw error if module exists and clobber=false (default)
- Add --clobber CLI flag to pgpm export command
- Non-destructive by default: existing modules are protected unless --clobber is specified

This prevents accidental overwriting of existing deploy/revert/verify directories
when re-exporting to an existing module.
@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

@pyramation pyramation closed this Dec 27, 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