[object Object]

← back to Silverleafwallpaper

Add Kamatera activation script for silver RML- feed (repopulate microsite_products + restart)

feba12a8a88a292b1b6569994c10b49f60465a30 · 2026-07-14 08:52:15 -0700 · Steve

Files touched

Diff

commit feba12a8a88a292b1b6569994c10b49f60465a30
Author: Steve <steve@designerwallcoverings.com>
Date:   Tue Jul 14 08:52:15 2026 -0700

    Add Kamatera activation script for silver RML- feed (repopulate microsite_products + restart)
---
 scripts/activate-kamatera.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/scripts/activate-kamatera.sh b/scripts/activate-kamatera.sh
new file mode 100644
index 0000000..1bb1b1d
--- /dev/null
+++ b/scripts/activate-kamatera.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+# activate-kamatera.sh — activate the RML- feed on the LIVE silverleafwallpaper.com.
+#
+# The live server reads dw_unified.microsite_products (not the static JSON), so
+# after the code+data are deployed this rebuilds that table for the slug:
+#   1. inherit the running app's DB env from pm2 (creds never printed)
+#   2. delete the stale rows for this slug
+#   3. migrate the 61 RML- products from the deployed data/products.json
+#   4. pm2 restart + HTTP verify
+#
+# Run ON Kamatera:  bash /var/www/silverleafwallpaper.com/scripts/activate-kamatera.sh
+set -euo pipefail
+
+SLUG=silverleafwallpaper
+SITE=/var/www/silverleafwallpaper.com
+MIGRATE=/root/Projects/_shared/scripts/migrate-microsite-products.js
+PM2_ID=29
+
+# Pull the DB connection env the live app uses, without echoing it.
+set -a
+eval "$(pm2 env "$PM2_ID" 2>/dev/null | grep -E '^(MICROSITE_DB_URL|DATABASE_URL|PGHOST|PGPORT|PGUSER|PGPASSWORD|PGDATABASE)=' || true)"
+set +a
+# migrate-microsite-products.js reads MICROSITE_DB_URL; fall back to DATABASE_URL.
+export MICROSITE_DB_URL="${MICROSITE_DB_URL:-${DATABASE_URL:-}}"
+
+PSQL=(psql)
+[ -n "${MICROSITE_DB_URL:-}" ] && PSQL=(psql "$MICROSITE_DB_URL")
+
+echo "== before =="
+"${PSQL[@]}" -tAc "select count(*) from microsite_products where site_slug='$SLUG';"
+
+echo "== delete stale slug rows =="
+"${PSQL[@]}" -c "delete from microsite_products where site_slug='$SLUG';"
+
+echo "== migrate RML- feed =="
+cd "$SITE"
+node "$MIGRATE" "$SITE"
+
+echo "== after =="
+"${PSQL[@]}" -tAc "select count(*) total, count(*) filter (where sku ilike 'RML-%') rml from microsite_products where site_slug='$SLUG';"
+
+echo "== restart + verify =="
+pm2 restart "$SLUG" --update-env >/dev/null 2>&1
+sleep 3
+curl -s "http://127.0.0.1:9912/api/products?limit=60" \
+  | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const j=JSON.parse(s);console.log("LIVE total:",j.total,"| all RML-:",j.items.every(p=>/rml-/i.test(p.sku||p.handle||"")),"| first:",j.items[0]&&j.items[0].title)})'

← 3a120f4 Fix product feed: show only the RML- Renaissance Metal Leaf  ·  back to Silverleafwallpaper  ·  Fix dead facet rails: replace vinyl/modern/textured/contempo 53299c7 →