← back to Dw Pairs Well

deploy/export-osp-flags.sh

13 lines

#!/bin/bash
# Export online_store_published flags from the LOCAL dw_unified mirror, with the
# provenance metadata fix-osp-kamatera.sh asserts on (export timestamp + row count).
set -euo pipefail
cd "$(dirname "$0")"
psql -d dw_unified -h /tmp -tA -F$'\t' -c \
  "SELECT shopify_id, online_store_published FROM shopify_products WHERE shopify_id IS NOT NULL AND online_store_published IS NOT NULL;" \
  > osp-flags.tsv
ROWS=$(wc -l < osp-flags.tsv | tr -d ' ')
printf 'exported_at=%s\nrows=%s\nsource=local dw_unified mirror (Mac2, /tmp socket)\n' \
  "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$ROWS" > osp-flags.meta
echo "exported $ROWS rows → osp-flags.tsv (+ .meta)"