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

feat: development environment seeding data script improvements #584

Merged
merged 4 commits into from
Jan 5, 2025

Conversation

kahlstrm
Copy link
Contributor

@kahlstrm kahlstrm commented Jan 5, 2025

Description

Previously when the dev db seeding was export from production DB, the versioned collections
didn't adhere to the 2-version limit due to production using higher version count retainment (100).
Also no images production were downloaded, leaving the development environment in a somewhat broken
state.

This PR addresses these two concerns with the following changes:

  • Create script for fetching contents for upload collections from prod

    • Running the payload script apps/cms/src/scripts/import-uploads.ts will iterate
      the local payload instance for the upload collections, check if the appropriate
      image file exists already locally, and if not it tries to download file from PAYLOAD_PRODUCTION_URL.
  • Create script for removing excess versions from mongo export

    • running scripts/remove-excess-versions.ts
  • run import from prod with new excess removal script

Due to Payload 2 being very nice and having SCSS imports mixed with the package, running the payload
script with Node doesn't work, hence the added requirement for bun. Maybe there could be
better workaround, but ¯\_(ツ)_/¯

Before submitting the PR, please make sure you do the following

  • If your PR is related to a previously discussed issue, please link to it here.
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Make sure the commit history is linear, up-to-date with main branch and does not contain any erroneous changes

Formatting and linting

  • Format code with pnpm format and lint the project with pnpm lint

@kahlstrm kahlstrm self-assigned this Jan 5, 2025
@kahlstrm kahlstrm force-pushed the feat/seeding-script-improvements branch 2 times, most recently from 9fb5f06 to 28968fa Compare January 5, 2025 06:17
@kahlstrm kahlstrm force-pushed the feat/seeding-script-improvements branch from 28968fa to 4dc1fe2 Compare January 5, 2025 06:19
@@ -13,6 +13,7 @@ Prerequisites:
- [Node.js](https://nodejs.org/en/), usage of [fnm](https://github.com/Schniz/fnm) or [nvm](https://github.com/nvm-sh/nvm) recommended
- [Docker](https://www.docker.com/) and docker-compose
- [MongoDB Database Tools](https://www.mongodb.com/docs/database-tools/installation/installation/) (for seeding the dev-db).
- [bun](https://bun.sh/) (for scripts that seed the dev-db & fetch uploads from prod).
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the scripts not work with Node?

echo "Copying uploads from apps/cms/uploads to db_data/gen/uploads..."
cp -r apps/cms/uploads data/gen
echo "cleaning up excess versions from versioned collections..."
bun run scripts/remove_excess_versions.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, could it try to default to Node if bun is not present?

@kahlstrm kahlstrm merged commit a3ec5d1 into main Jan 5, 2025
3 checks passed
@kahlstrm kahlstrm deleted the feat/seeding-script-improvements branch January 5, 2025 11:17
kahlstrm added a commit that referenced this pull request Jan 6, 2025
…nts (#584)

* feat: create script for fetching contents for upload collections from prod

* feat: create script for removing excess versions from mongo export

* chore: run import from prod with new scripts

* fix: add fallback to node for generate_seeding_data script
kahlstrm added a commit that referenced this pull request Jan 21, 2025
…nts (#584)

* feat: create script for fetching contents for upload collections from prod

* feat: create script for removing excess versions from mongo export

* chore: run import from prod with new scripts

* fix: add fallback to node for generate_seeding_data script
kahlstrm added a commit that referenced this pull request Feb 4, 2025
…nts (#584)

* feat: create script for fetching contents for upload collections from prod

* feat: create script for removing excess versions from mongo export

* chore: run import from prod with new scripts

* fix: add fallback to node for generate_seeding_data script
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