Skip to content

Conversation

@ymadobe
Copy link
Contributor

@ymadobe ymadobe commented Nov 18, 2025

For each Site:

If projectId is missing:

  1. Derives a projectName from the registrable domain of baseURL (e.g. bulk.com, xbox.com).
  2. Finds or creates a Project for (organizationId, projectName).
  3. Sets site.projectId to that project’s id.
  4. If language or region are missing:Uses detectLocale to infer them, with fallback en/US.
  5. Sets updatedBy = "system" when writing.

Script Usage :

Table selection via env:

export DYNAMO_TABLE_NAME_DATA=spacecat-services-data # or any Spacecat table export AWS_REGION=us-east-1

Dry run (no writes, with report):

node packages/spacecat-shared-data-access/scripts/migrate-sites-to-projects-and-locales.mjs \ --orgId=<ORG_ID> \ --report \ --dry-run \ --concurrency=10 \ --no-network

Apply (perform writes, with report):

node packages/spacecat-shared-data-access/scripts/migrate-sites-to-projects-and-locales.mjs \ --orgId=<ORG_ID> \ --apply \ --yes \ --report \ --concurrency=10 \ --no-network

Supported filters: --orgId, --projectId, --domain, --siteId. Reports are written to packages/spacecat-shared-data-access/reports/ as CSV and JSON with columns: siteId, organizationId, baseURL, projectId, language, region, action.

@github-actions
Copy link

This PR will trigger a patch release when merged.

const effectiveConcurrency = Number.isFinite(concurrency) && concurrency > 0
? concurrency
: 10;
await mapWithConcurrency(sites, effectiveConcurrency, processOne);
Copy link
Member

Choose a reason for hiding this comment

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

I would highly recommend to not use any concurrency in this script. Since the script should re-use projects for sites onboarded with multiple locales (e.g. bulk.com/uk and bulk.com/fr should both use project bulk.com), you might run into issues when both sites are created at the same time while the database wasn't updated yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, updated the script to not use concurrency.

@ymadobe ymadobe requested a review from herzog31 November 19, 2025 09:11
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.

3 participants