From 1c91d578990e070e11d345a638fd23232780154e Mon Sep 17 00:00:00 2001 From: Brendon Heinst Date: Tue, 24 Feb 2026 16:55:35 +0100 Subject: [PATCH] Add Sanity seed migration to deploy scripts --- src/scripts/deploy.ts | 20 ++++++++++++++++++++ start.sh | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 src/scripts/deploy.ts diff --git a/src/scripts/deploy.ts b/src/scripts/deploy.ts new file mode 100644 index 0000000..633a365 --- /dev/null +++ b/src/scripts/deploy.ts @@ -0,0 +1,20 @@ +import { ExecArgs } from "@medusajs/framework/types" +import { ContainerRegistrationKeys } from "@medusajs/framework/utils" +import syncSanity from "./sync-sanity" +import linkProducts from "./link-products" + +export default async function deploy({ container }: ExecArgs) { + const logger = container.resolve(ContainerRegistrationKeys.LOGGER) + + logger.info("=== Starting deployment sync ===") + + // 1. Sync products from Sanity + logger.info("--- Step 1: Syncing products from Sanity ---") + await syncSanity({ container }) + + // 2. Link products to sales channel and set inventory + logger.info("--- Step 2: Linking products and setting inventory ---") + await linkProducts({ container }) + + logger.info("=== Deployment sync complete ===") +} diff --git a/start.sh b/start.sh index 125db88..976e9d9 100644 --- a/start.sh +++ b/start.sh @@ -1,5 +1,7 @@ #!/bin/sh echo "Running database migrations..." npx medusa db:migrate +echo "Running deployment sync (Sanity + product linking)..." +npx medusa exec ./src/scripts/deploy.js echo "Starting Medusa server..." npx medusa start