Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Dec 27, 2025

Summary

Adds interactive prompts to the pgpm export command for two scenarios:

  1. Module overwrite confirmation: When exporting to a module that already exists, prompts the user with "Module exists. Overwrite? [y/N]" before deleting deploy/revert/verify directories
  2. Missing module auto-install: Detects which pgpm modules from the required extensions list are missing from the workspace and offers to install them automatically

The prompter parameter is now threaded through exportMigrationsexportMigrationsToDiskpreparePackage and promptAndInstallMissingModules. When no prompter is provided (non-interactive mode), the existing behavior is preserved.

Code Organization

  • PGPM_MODULE_MAP and getMissingInstallableModules() extracted to pgpm/core/src/modules/modules.ts for reusability
  • DB_REQUIRED_EXTENSIONS and SERVICE_REQUIRED_EXTENSIONS constants hoisted to top of export-migrations.ts
  • Uses getInstalledModules() for accurate detection of installed npm packages

Updates since last revision

  • Moved PGPM_MODULE_MAP and detection logic to modules/modules.ts (more generic location near module installation code)
  • Added MissingModule interface for type safety
  • Hoisted extension constants (DB_REQUIRED_EXTENSIONS, SERVICE_REQUIRED_EXTENSIONS) per code review feedback
  • Renamed checkAndInstallMissingModulespromptAndInstallMissingModules for clarity
  • Switched from getModuleMap() to getInstalledModules() for more accurate installed module detection

Review & Testing Checklist for Human

  • Verify PGPM_MODULE_MAP accuracy: The mapping was built by inspecting the pgpm-modules repo. Confirm all 11 entries are correct and no modules are missing
  • Test project.getInstalledModules() return value: The code compares against installed array which should contain npm package names (e.g., @pgpm/base32) - verify this matches actual behavior
  • Test project.installModules() with npm package names: The code passes @pgpm/base32 style names - verify this is the expected format
  • Manual E2E test: Run pgpm export on a database with existing modules and verify:
    • Overwrite prompt appears when module exists
    • Missing module detection works correctly
    • Module installation succeeds when confirmed

Notes

  • No unit tests were added for the new functionality
  • When user declines overwrite, an error is thrown (Export cancelled: Module "X" already exists.) - consider if this is the desired UX

Requested by: Dan Lynch (@pyramation)
Devin session: https://app.devin.ai/sessions/7e7813472a0643aa88ccb509b288050a

- Add PGPM_MODULE_MAP constant mapping control file names to npm package names
- Add Prompter interface for interactive prompts
- Add checkAndInstallMissingModules function to detect and install missing pgpm modules
- Modify preparePackage to prompt user before overwriting existing modules
- Update exportMigrations and exportMigrationsToDisk to accept prompter parameter
- Update CLI export command to pass prompter through to exportMigrations
- Move prompter.close() to after exportMigrations completes
@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

- Move PGPM_MODULE_MAP and getMissingInstallableModules to modules/modules.ts
- Add MissingModule interface for type safety
- Hoist DB_REQUIRED_EXTENSIONS and SERVICE_REQUIRED_EXTENSIONS constants
- Rename checkAndInstallMissingModules to promptAndInstallMissingModules
- Use getInstalledModules() instead of getModuleMap() for accurate detection
@pyramation pyramation merged commit fdcff26 into main Dec 27, 2025
34 checks passed
@pyramation pyramation deleted the devin/1766801181-export-flow-improvements branch December 27, 2025 02:31
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