Skip to content
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: sync changes from pg branch #36556

Merged
merged 4 commits into from
Oct 16, 2024
Merged

chore: sync changes from pg branch #36556

merged 4 commits into from
Oct 16, 2024

Conversation

AnaghHegde
Copy link
Member

@AnaghHegde AnaghHegde commented Sep 26, 2024

Description

Added the changes from move to pg script from the postgres branch to keep in sync.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced data transformation process for improved compatibility with Postgres.
    • Introduced mapping for _class field to type field.
  • Bug Fixes

    • Improved handling of asynchronous operations during MongoDB client instantiation.
  • Refactor

    • Clarified condition checks in data transformation logic for better readability.

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11100769096
Commit: 46e043c
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Mon, 30 Sep 2024 07:14:51 UTC

/ok-to-test tags="@tag.Sanity"

Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

Walkthrough

The changes in this pull request focus on enhancing the move-to-postgres.mjs script, which is responsible for migrating data from MongoDB to PostgreSQL. Key modifications include the introduction of a new function, mapClassToType, which facilitates the mapping of _class values to type values. Additionally, the transformFields function has been updated to incorporate this new mapping, and the clarity of the replacer function has been improved. Overall, these changes aim to streamline the migration process and ensure better compatibility with PostgreSQL.

Changes

File Path Change Summary
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs - Added mapClassToType function for _class to type mapping.
- Enhanced transformFields to utilize the new mapping.
- Clarified replacer function's object checking condition.

Suggested labels

Move to Postgres, DB Infrastructure Pod

Suggested reviewers

  • sharat87
  • abhvsn

Poem

In the world of code, a shift takes flight,
Mongo to Postgres, the future looks bright.
With functions refined and paths made clear,
Data flows smoothly, migration draws near.
So let’s celebrate this change with cheer,
For every line written brings progress here! 🎉


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Sep 26, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5a4174a and 5564b39.

📒 Files selected for processing (1)
  • deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs (5 hunks)
🧰 Additional context used
Biome
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs

[error] 135-135: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


[error] 157-157: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 163-163: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🔇 Additional comments not posted (2)
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs (2)

19-19: Simplified 'EXPORT_ROOT' Constant

Well done simplifying the EXPORT_ROOT constant to a relative directory name. This enhances the portability of your script.


93-93: Appropriate Use of 'transformFields' Function

Good job invoking transformFields(doc). This ensures that the documents are properly transformed to handle the _class to type conversion, which is essential for Postgres compatibility.

@AnaghHegde AnaghHegde self-assigned this Sep 26, 2024
Copy link
Contributor

@abhvsn abhvsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added couple of comments.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs (1)

171-185: Excellent addition of the mapClassToType function!

This new function is a great way to organize our _class to type mappings. Good job!

However, let's think about the future. Can anyone suggest how we might make this function more extensible?

Here's an idea to consider:

const classToTypeMap = {
  "com.appsmith.external.models.DatasourceStructure$PrimaryKey": "primary key",
  "com.appsmith.external.models.DatasourceStructure$ForeignKey": "foreign key",
  // Add more mappings here
};

function mapClassToType(_class) {
  return classToTypeMap[_class] || null;
}

This approach would make it easier to add new mappings in the future. What do you think?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5564b39 and f1fd05d.

📒 Files selected for processing (1)
  • deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs (3 hunks)
🧰 Additional context used
🪛 Biome
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs

[error] 136-136: Use Array.isArray() instead of instanceof Array.

instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.

(lint/suspicious/useIsArray)


[error] 158-158: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 164-164: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🔇 Additional comments (1)
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs (1)

150-153: A+ for documentation!

I'm impressed with the updates to the comments. They clearly explain the new _class to type transformation. This is exactly what we want to see - code changes accompanied by clear, concise documentation.

Keep up the good work, and remember: well-documented code is happy code!

@AnaghHegde AnaghHegde added the ok-to-test Required label for CI label Sep 26, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f1fd05d and 46e043c.

📒 Files selected for processing (1)
  • deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs (2 hunks)
🧰 Additional context used
📓 Learnings (2)
📓 Common learnings
Learnt from: abhvsn
PR: appsmithorg/appsmith#36556
File: deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs:159-164
Timestamp: 2024-09-30T06:28:31.291Z
Learning: When transforming the `_class` field in `move-to-postgres.mjs`, if `mapClassToType` returns `null`, retain the original `_class` value in the `type` field to preserve important MongoDB information.
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs (1)
Learnt from: abhvsn
PR: appsmithorg/appsmith#36556
File: deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs:159-164
Timestamp: 2024-09-30T06:28:31.291Z
Learning: When transforming the `_class` field in `move-to-postgres.mjs`, if `mapClassToType` returns `null`, retain the original `_class` value in the `type` field to preserve important MongoDB information.
🪛 Biome
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs

[error] 158-158: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 164-164: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🔇 Additional comments (2)
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs (2)

94-94: Excellent update to the comment, class!

I'm pleased to see this informative comment update. It clearly explains that the transformFields function now handles the _class to type transformation. This is a great example of keeping your code documentation up-to-date with changes in functionality. Well done!


150-153: A gold star for documentation!

Excellent work on updating the function documentation! It's crucial to keep our documentation in sync with code changes. This update clearly explains the new functionality of replacing the _class field with an appropriate type field.

Remember, class: clear and up-to-date documentation is key to maintaining a healthy codebase!

Copy link

github-actions bot commented Oct 7, 2024

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Oct 7, 2024
Copy link

This PR has been closed because of inactivity.

@github-actions github-actions bot closed this Oct 15, 2024
@AnaghHegde AnaghHegde reopened this Oct 16, 2024
@AnaghHegde AnaghHegde merged commit 060cf92 into release Oct 16, 2024
56 of 57 checks passed
@AnaghHegde AnaghHegde deleted the chore/pg-move-script branch October 16, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants