-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Connect move-to-postgres
to appsmithctl
#38298
base: release
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request introduces a new command for migrating data from MongoDB to PostgreSQL. A new TypeScript implementation replaces a previous JavaScript module, adding enhanced functionality for data migration. The changes include updating the command handling in the index file to support the new "move-to-postgres" command, with a comprehensive script that handles MongoDB data extraction, transformation, and preparation for PostgreSQL migration. Changes
Sequence DiagramsequenceDiagram
participant CLI as Command Line Interface
participant Index as Command Handler
participant MoveScript as Move to Postgres Script
participant MongoDB as MongoDB Database
participant Export as Export Directory
CLI->>Index: Execute "move-to-postgres"
Index->>MoveScript: Invoke migration
MoveScript->>MongoDB: Connect and validate data
MongoDB-->>MoveScript: Return collections
MoveScript->>MoveScript: Transform documents
MoveScript->>Export: Write transformed data
MoveScript-->>CLI: Complete migration
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
/build-deploy-preview skip-tests=true |
Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12442844203. |
Deploy-Preview-URL: https://ce-38298.dp.appsmith.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
app/client/packages/rts/src/ctl/move-to-postgres.ts (4)
20-45
: Check argument parsing for clarity
Your approach to parsing command-line arguments is straightforward. It might be beneficial to add comments clarifying valid combinations and how each flag should be used, especially since they can’t co-exist (e.g., specifying both mongoDbUrl and mongoDumpFile).
46-50
: Graceful exit message
When neither a MongoDB URL nor a dump file is provided, consider including usage instructions in the error message to guide the user on how to supply arguments.
103-114
: Enforce stable version check
The check for the stable version of MongoDB data (via mongockChangeLog) is clear. However, ensure any logging or documentation explicitly states that upgrading Appsmith is required if this validation fails, as it can save users time diagnosing.
186-207
: Avoid the delete operator for better performance
Static analysis suggests avoiding the “delete” operator (lines 196 and 202) due to potential performance overhead. You could set these fields to undefined instead or restructure the object differently. For instance:- delete obj._id; + obj._id = undefined; - delete obj._class; + obj._class = undefined;🧰 Tools
🪛 Biome (1.9.4)
[error] 196-196: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 202-202: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
app/client/packages/rts/src/ctl/index.ts (1)
12-12
: Ensure proper code splitting and bundling
Importing “moveToPostgres” at the top is fine. If the rest of the script is large, consider dynamic import for performance when this command is rarely used.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
app/client/packages/rts/src/ctl/index.ts
(2 hunks)app/client/packages/rts/src/ctl/move-to-postgres.mjs
(0 hunks)app/client/packages/rts/src/ctl/move-to-postgres.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- app/client/packages/rts/src/ctl/move-to-postgres.mjs
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/packages/rts/src/ctl/move-to-postgres.ts
[error] 196-196: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 202-202: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
🔇 Additional comments (3)
app/client/packages/rts/src/ctl/move-to-postgres.ts (2)
51-72
: Manage asynchronous tasks with event handling
Spawning the “mongod” process followed by an immediate “mongorestore” call is workable. However, to reduce potential race conditions, consider waiting for the “mongod” process to confirm readiness before invoking “mongorestore.”
164-166
: Validate archived logic
Your archived-object detection method is direct. If you need to conditionally ignore partial archives (e.g., only soft-deleted records), clarify that in comments to avoid confusion around handling “deletedAt” vs “deleted = true.”
app/client/packages/rts/src/ctl/index.ts (1)
64-65
: Impressive addition
The “move-to-postgres” command nicely integrates with the existing command structure. This is consistent with other commands and should be easy to maintain moving forward.
This PR makes the
move-to-postgres
script available fromappsmithctl
.Automation
/test sanity
🔍 Cypress test results
Caution
If you modify the content in this section, you are likely to disrupt the CI result for your PR.
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
New Features
Bug Fixes
Chores