[object Object]

← back to Wallco Ai

refresh_designs_snapshot: platform-aware psql (Linux sudo postgres, macOS direct)

93f442362cba8f1634ef73b6a04a329518deddfb · 2026-05-11 19:45:06 -0700 · SteveStudio2

Was throwing role 'root' does not exist on every bake-triggered snapshot
regen, leaving the public catalog stale even though spoon_all_designs
inserts succeeded. Same shim used in server.js psqlQuery + generate_designs.js.

Files touched

Diff

commit 93f442362cba8f1634ef73b6a04a329518deddfb
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date:   Mon May 11 19:45:06 2026 -0700

    refresh_designs_snapshot: platform-aware psql (Linux sudo postgres, macOS direct)
    
    Was throwing role 'root' does not exist on every bake-triggered snapshot
    regen, leaving the public catalog stale even though spoon_all_designs
    inserts succeeded. Same shim used in server.js psqlQuery + generate_designs.js.
---
 scripts/refresh_designs_snapshot.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/scripts/refresh_designs_snapshot.py b/scripts/refresh_designs_snapshot.py
index 07d189e..f24e444 100644
--- a/scripts/refresh_designs_snapshot.py
+++ b/scripts/refresh_designs_snapshot.py
@@ -17,7 +17,14 @@ ROOT = Path.home() / 'Projects' / 'wallco-ai'
 OUT  = ROOT / 'data' / 'designs.json'
 
 def psql_json(sql):
-    out = subprocess.run(['psql','dw_unified','-At','-q','-c',sql], capture_output=True, text=True, check=True).stdout.strip()
+    # Linux (Kamatera): pm2 runs as root, no 'root' PG role → sudo postgres
+    # macOS (Mac2): local trust auth, direct psql works
+    import sys as _sys
+    if _sys.platform.startswith('linux'):
+        cmd = ['sudo','-n','-u','postgres','psql','dw_unified','-At','-q','-c',sql]
+    else:
+        cmd = ['psql','dw_unified','-At','-q','-c',sql]
+    out = subprocess.run(cmd, capture_output=True, text=True, check=True).stdout.strip()
     return json.loads(out) if out else []
 
 def hex_to_hls(hex_):

← f3c9acd Fix /age-themes after debate-team review — strip fabricated  ·  back to Wallco Ai  ·  Apply debate-team fixes to /age-themes — implement APCA-W3 L 3055bb2 →