← back to Japan Enrich
db/TIER1-STAGE.md
41 lines
# Tier 1 — stage Japan into CANONICAL dw_unified (on_shopify=false, NO Shopify)
APPROVED 2026-07-06 (Steve). Stages the Sangetsu line into canonical `dw_unified`
with `us_distributor='Goodrich (Thailand)'`, `on_shopify=false`. **Does NOT publish to
Shopify** (Tier 2 stays settlement-gated). Runs ON Kamatera so it reads the LIVE staging
file (18,272 SKUs), not the smaller Mac2 copy. Additive + reversible.
## 1. Push the scripts (from Mac2)
```sh
rsync -avz ~/Projects/japan-enrich/db/ root@45.61.58.125:/root/Projects/japan-staging-viewer/db/
```
## 2. On Kamatera — install pg, create tables, stage, verify
```sh
ssh root@45.61.58.125
cd /root/Projects/japan-staging-viewer
npm i pg
# canonical dw_unified DSN — pull from your DW env (do NOT hardcode):
export DATABASE_URL=$(grep -m1 '^DATABASE_URL=' /root/Projects/Designer-Wallcoverings/.env | cut -d= -f2-)
psql "$DATABASE_URL" -c 'select current_database()' # sanity: dw_unified
# a) tables (additive; UNIQUE(vendor_code,mfr_sku) for the upsert)
psql "$DATABASE_URL" -f db/create-japan-catalog-tables.sql
# b) stage the FULL live Sangetsu line (reads ../staging/sangetsu-staging.jsonl = 18,272)
node db/stage-sangetsu-all.js
# c) verify — expect ~18,272 rows, all Goodrich (Thailand), on_shopify all false
psql "$DATABASE_URL" -c "select us_distributor, count(*), bool_or(on_shopify) any_live from sangetsu_catalog group by 1"
```
## Rollback
```sh
psql "$DATABASE_URL" -c "truncate sangetsu_catalog" # or: drop table sangetsu_catalog;
```
## Do NOT (Tier 2 — still gated)
- No `on_shopify=true`, no Shopify product create/publish.
- Sangetsu murals (~60% birds/tropical) must clear the `settlement` gate before ANY publish.