Skip to content

chore: Add mover script for Mongo to postgres migration#36458

Merged
abhvsn merged 7 commits intoreleasefrom
chore/add-regen-pg-data-script
Sep 25, 2024
Merged

chore: Add mover script for Mongo to postgres migration#36458
abhvsn merged 7 commits intoreleasefrom
chore/add-regen-pg-data-script

Conversation

@abhvsn
Copy link
Contributor

@abhvsn abhvsn commented Sep 20, 2024

Description

PR to add:

  1. Mover script : move-to-postgres.sh
  2. Baseline data generation: regen-baseline.sh

/test Sanity

🔍 Cypress test results

Tip

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


Wed, 25 Sep 2024 06:54:08 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration file for instance management and permission groups.
    • Added a custom JavaScript library for XML parsing.
    • Implemented multiple database and API plugins, enhancing integration capabilities.
    • Established a tenant configuration for managing tenant-specific settings.
    • Added an anonymous user entity for improved user management.
  • Bug Fixes

    • Improved data migration script from MongoDB to Postgres.
  • Documentation

    • Updated scripts for baseline data generation and migration processes.

@abhvsn abhvsn self-assigned this Sep 20, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 20, 2024

Walkthrough

The changes introduce several new configuration files and entities for the Appsmith application, including permission groups, plugins, user definitions, and a tenant configuration. Key additions include a custom JavaScript library for XML parsing, a migration script for transferring data from MongoDB to PostgreSQL, and a script for generating baseline data. Overall, these modifications enhance the application's structure and functionality, allowing for improved data management and user permissions.

Changes

File Path Change Summary
deploy/docker/fs/opt/appsmith/baseline-ce/*.jsonl New configuration entries for instance ID, instance configuration, public permission groups, and tenant settings.
deploy/docker/fs/opt/appsmith/baseline-ce/customJSLib.jsonl Introduction of a custom JavaScript library named xmlParser with multiple XML-related functions.
deploy/docker/fs/opt/appsmith/baseline-ce/permissionGroup.jsonl Addition of new permission groups, including "Instance Administrator Role" and "publicPermissionGroup".
deploy/docker/fs/opt/appsmith/baseline-ce/plugin.jsonl Addition of multiple plugins for various data sources, including PostgreSQL, MongoDB, and several AI services.
deploy/docker/fs/opt/appsmith/baseline-ce/sequence.jsonl New entry defining a datasource sequence with an ID and next number.
deploy/docker/fs/opt/appsmith/baseline-ce/tenant.jsonl New tenant configuration with attributes for managing tenant-specific settings.
deploy/docker/fs/opt/appsmith/baseline-ce/user.jsonl Introduction of an anonymous user entity with specific attributes for user management.
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs New script for migrating data from MongoDB to PostgreSQL, including data transformation logic.
scripts/regen-baseline.sh New Bash script to automate the generation of baseline data for the Appsmith application.

Possibly related PRs

Suggested labels

skip-changelog, ok-to-test

Poem

In the world of code, new paths we pave,
With plugins and scripts, our data we save.
From Mongo to Postgres, a journey so bright,
Anonymous users now take flight!
Configuration entries, oh what a delight,
Appsmith evolves, reaching new heights! 🎉


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.

@abhvsn abhvsn requested a review from AnaghHegde September 20, 2024 12:27
@abhvsn abhvsn added the ok-to-test Required label for CI label Sep 20, 2024
@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 20, 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: 10

Outside diff range and nitpick comments (4)
deploy/docker/fs/opt/appsmith/baseline-ce/permissionGroup.jsonl (1)

2-2: The "publicPermissionGroup" permission group is structured correctly.

The JSON object adheres to the expected schema for a permission group. Given that this group is intended for anonymous user access, the empty "permissions" and "policies" arrays are understandable.

As a suggestion, consider adding a policy to explicitly grant read access to public resources, if applicable. This would make the purpose of the group clearer and ensure consistent access control for anonymous users.

scripts/regen-baseline.sh (1)

17-19: Correct typographical errors in the documentation.

Please address the following typographical errors to improve clarity:

  • "everytime" should be "every time".
  • "passover" should be "pass over".
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs (1)

116-117: Remove Unnecessary process.exit(0); Statement

Explicitly calling process.exit(0); is not required at the end of the script. The Node.js process will exit naturally when all asynchronous operations are complete.

You can safely remove these lines:

-// TODO(Shri): We shouldn't need this.
-process.exit(0);

This makes the code cleaner and avoids any unintended side effects.

deploy/docker/fs/opt/appsmith/baseline-ce/plugin.jsonl (1)

2-2: Consider using an SVG icon for better scalability

In line 2, the 'iconLocation' for the REST API plugin points to a PNG file:

"iconLocation":"https://assets.appsmith.com/RestAPI.png"

SVG files are scalable and provide better performance across different screen resolutions. If an SVG version of the icon is available, it would be beneficial to use it for consistency and optimal display.

You can update the icon location as follows:

- "iconLocation":"https://assets.appsmith.com/RestAPI.png"
+ "iconLocation":"https://assets.appsmith.com/logo/restapi.svg"
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9bbf794 and 07efadf.

Files selected for processing (9)
  • deploy/docker/fs/opt/appsmith/baseline-ce/config.jsonl (1 hunks)
  • deploy/docker/fs/opt/appsmith/baseline-ce/customJSLib.jsonl (1 hunks)
  • deploy/docker/fs/opt/appsmith/baseline-ce/permissionGroup.jsonl (1 hunks)
  • deploy/docker/fs/opt/appsmith/baseline-ce/plugin.jsonl (1 hunks)
  • deploy/docker/fs/opt/appsmith/baseline-ce/sequence.jsonl (1 hunks)
  • deploy/docker/fs/opt/appsmith/baseline-ce/tenant.jsonl (1 hunks)
  • deploy/docker/fs/opt/appsmith/baseline-ce/user.jsonl (1 hunks)
  • deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs (1 hunks)
  • scripts/regen-baseline.sh (1 hunks)
Additional context used
Biome
deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs

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

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[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)

Additional comments not posted (14)
deploy/docker/fs/opt/appsmith/baseline-ce/sequence.jsonl (1)

1-1: Great work on defining the data source object! 🌟

The JSON object in this file has a valid structure and consistent property values. The id appears to be a unique identifier, the name suggests it represents a data source, and the nextNumber could be a sequence or version number.

However, to fully understand the impact and purpose of this change, it would be helpful to have some additional context. 🤔

Could you please provide some more information about how this file is used within the Appsmith application? Understanding the broader context will allow us to provide more meaningful feedback and ensure this change aligns with the overall system design. 📚

deploy/docker/fs/opt/appsmith/baseline-ce/user.jsonl (1)

1-1: Great work! The JSON object looks good.

The JSON object represents a valid system-generated anonymous user entity for the Appsmith application. The properties are set correctly, and the presence of this user in the baseline data suggests that it is a necessary part of the application's user management system.

Keep up the good work!

deploy/docker/fs/opt/appsmith/baseline-ce/tenant.jsonl (1)

1-1: Great work on the tenant configuration JSON! 🌟

The JSON object follows a well-defined structure and includes essential tenant-specific settings and permissions. The inclusion of permission policies and groups allows for granular access control and authorization management within the Appsmith application.

The migration status field set to "COMPLETED" indicates a successful data migration process for the tenant, which is a positive sign.

Keep up the excellent work in defining and managing tenant configurations! 👍

deploy/docker/fs/opt/appsmith/baseline-ce/customJSLib.jsonl (1)

1-1: Excellent work on adding the custom JavaScript library for XML parsing! 👏

The JSON object is well-structured and includes all the necessary details like the library name, function definitions, CDN URL, and version. Loading the library from a trusted CDN source is a smart choice as it ensures availability and reduces maintenance efforts.

Keep up the great work in extending the application's functionality through such useful libraries! 🌟

deploy/docker/fs/opt/appsmith/baseline-ce/permissionGroup.jsonl (1)

1-1: Well done! The "Instance Administrator Role" permission group looks good.

The JSON object follows the expected structure for a permission group. The policies granting the ability to manage the group itself are appropriately defined. Keep up the great work!

deploy/docker/fs/opt/appsmith/baseline-ce/config.jsonl (4)

1-1: Great work! The instance ID configuration looks good.

This JSON object correctly defines the instance ID configuration with appropriate fields and values. The empty policies array and policyMap object indicate no specific policies are applied to this configuration, which is acceptable.


2-2: Excellent! The instance configuration is properly defined.

This JSON object accurately represents the instance configuration with suitable fields and values. The policies array and policyMap object correctly grant read and manage permissions for the instance configuration to the default permission group specified in the config field. Well done!


3-3: Nicely done! The public permission group configuration is properly set up.

This JSON object correctly defines the public permission group configuration with appropriate fields and values. The empty policies array and policyMap object indicate no specific policies are applied to this permission group, which is acceptable for a public group.


4-4: Splendid! The schema version configuration is accurately defined.

This JSON object correctly represents the schema version configuration with appropriate fields and values. The config field properly sets the schema version number to 2. The empty policies array and policyMap object indicate no specific policies are applied to this configuration, which is acceptable for a schema version setting. Good job!

scripts/regen-baseline.sh (1)

39-41: Verify the source file path in 'docker cp'.

Ensure that the file path $project_root/deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs is correct and the file exists. This will prevent errors during the docker cp command when copying the script into the container.

You can verify the file's existence by running:

deploy/docker/fs/opt/appsmith/baseline-ce/plugin.jsonl (4)

1-24: Excellent work on adding the plugin configurations!

You've carefully structured each plugin entry, ensuring that all necessary fields are included. This comprehensive list will significantly enhance the application's capabilities by supporting a wide range of services.


13-13: Consistency check for 'generateCRUDPageComponent' values

In line 13, the 'generateCRUDPageComponent' for the 'Snowflake' plugin is set to 'SQL'. Ensure that this value accurately reflects the component used for generating CRUD pages for Snowflake and that it's consistent with similar database plugins.

To verify all occurrences of 'generateCRUDPageComponent', run:

#!/bin/bash
# Description: List all 'generateCRUDPageComponent' values in plugins

grep '"generateCRUDPageComponent"' deploy/docker/fs/opt/appsmith/baseline-ce/plugin.jsonl

12-12: Add 'generateCRUDPageComponent' to the Google Sheets plugin

The 'Google Sheets' plugin in line 12 lacks the 'generateCRUDPageComponent' field, which is present in other plugins that support CRUD operations. Including this field enables automatic generation of CRUD pages, enhancing user experience.

You can add the field as shown:

 "uiComponent":"UQIDbEditorForm",
+ "generateCRUDPageComponent":"Google Sheets",

Likely invalid or redundant comment.


12-12: Verify the 'isSupportedForAirGap' setting for the Google Sheets plugin

In line 12, the 'isSupportedForAirGap' property is set to false for the Google Sheets plugin:

"isSupportedForAirGap":false

All other plugins have this property set to true. Please confirm whether Google Sheets genuinely lacks support for air-gapped environments or if this was unintentional. Ensuring consistency here is important for users operating in restricted networks.

To check for plugins where 'isSupportedForAirGap' is false, you can run:

Verification successful

Class, let's review our findings on the 'isSupportedForAirGap' setting for the Google Sheets plugin. Pay attention now!

The 'isSupportedForAirGap' setting for Google Sheets is correct

After a thorough examination, we can conclude that the 'isSupportedForAirGap' property being set to false for the Google Sheets plugin is intentional and correct. Here's why:

  1. Google Sheets is a SAAS (Software as a Service) type plugin, which inherently requires internet connectivity.
  2. It utilizes OAuth2 for authentication, a process that typically needs online access.
  3. The plugin is marked as dependent on CS (likely Cloud Services), indicating a reliance on external connectivity.

These characteristics make it impossible for the Google Sheets plugin to function in an air-gapped environment, hence the appropriate setting of 'isSupportedForAirGap' to false.

Remember, class: in the world of software, sometimes being different is not a mistake, but a necessity based on the unique requirements of each component!

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: List plugins with 'isSupportedForAirGap' set to false

grep '"isSupportedForAirGap":false' deploy/docker/fs/opt/appsmith/baseline-ce/plugin.jsonl

Length of output: 4790

@abhvsn abhvsn added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Sep 24, 2024
@abhvsn abhvsn merged commit 1210104 into release Sep 25, 2024
@abhvsn abhvsn deleted the chore/add-regen-pg-data-script branch September 25, 2024 09:52
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 2024
…36458)

## Description
PR to add:
1. Mover script : move-to-postgres.sh
2. Baseline data generation: regen-baseline.sh

/test Sanity

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11027514472>
> Commit: c565b7a
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11027514472&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Wed, 25 Sep 2024 06:54:08 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced a new configuration file for instance management and
permission groups.
	- Added a custom JavaScript library for XML parsing.
- Implemented multiple database and API plugins, enhancing integration
capabilities.
- Established a tenant configuration for managing tenant-specific
settings.
	- Added an anonymous user entity for improved user management.

- **Bug Fixes**
	- Improved data migration script from MongoDB to Postgres.

- **Documentation**
	- Updated scripts for baseline data generation and migration processes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants