PromucFlow_constructor/scripts/regen-baseline.sh
Abhijeet 1210104575
chore: Add mover script for Mongo to postgres migration (#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: c565b7a4d832b0d0e75df2f3122a1c0679235e88
> <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 -->
2024-09-25 15:22:02 +05:30

67 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if [[ ${TRACE-0} == 1 ]]; then
set -o xtrace
fi
#
# 1. Run a new Appsmith container.
# 2. Wait for, and ensure backend server is up.
# 3. Kill backend.
# 4. Ensure connection to the embedded MongoDB.
# 5. Run the export script against the embedded MongoDB.
# 6. If needed, move the jsonl files to the right place.
# 7. Remove the container.
#
# Unfortunately, everytime this script runs, there will be a diff in the jsonl files. Always. This is because the ObjectID
# values, and the "createdAt" values would be different everytime a new Appsmith container is started up. This is...
# _okay_ for now. Since once we passover to only writing migrations on Postgres, these files will effectively be sealed.
# So we have to put up with that "problem" only until then. Which makes it not worth our time to solve.
# That said, please carefully review the diff nevertheless, keeping in mind the implementation of the migrations that
# reads these files.
container_name=appsmith-for-baseline
project_root="$(git rev-parse --show-toplevel)"
edition=ce
if [[ "$(git remote get-url origin)" == *appsmithorg/appsmith-ee.git ]]; then
edition=ee
fi
docker rm --force "$container_name"
docker run \
--detach \
--name "$container_name" \
--pull always "appsmith/appsmith-$edition":release
docker cp \
"$project_root/deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs" \
"$container_name":/opt/appsmith/utils/export.mjs
docker exec "$container_name" bash -c '
set -o errexit
set -o nounset
for attempt in {1..99}; do
if curl --silent --fail --fail-early 127.0.0.1:8080/api/v1/health; then
break
fi
echo "Waiting for backend to come up..."
sleep 3
done
if ! supervisorctl stop editor postgres rts backend redis; then
echo "Warning: Some services may not have stopped correctly."
fi
source /appsmith-stacks/configuration/docker.env
node utils/export.mjs --mongodb-url="$APPSMITH_DB_URL" --baseline
'
baseline_dir="$project_root/deploy/docker/fs/opt/appsmith/baseline-$edition"
rm -rf "$baseline_dir"
docker cp "$container_name":/appsmith-stacks/mongo-data "$baseline_dir"
docker rm -f "$container_name"
echo Removed "$container_name" and copied the new baseline files.
echo Finish