#!/usr/bin/env python3 """Apply ExposedGays Supabase functions + seed if missing.""" import paramiko HOST = "10.10.0.11" USER = "localadministrator" PASS = "Bbt9115xty9176!" c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect(HOST, username=USER, password=PASS, timeout=20, allow_agent=False, look_for_keys=False) def run(cmd, t=120): print("$", cmd[:140]) _, o, e = c.exec_command(cmd, timeout=t) code = o.channel.recv_exit_status() out = (o.read() + e.read()).decode(errors="replace") print(out[-3000:]) print("exit", code, "\n") return code # Pipe functions.sql into postgres with open(r"C:\Users\Local Administrator\exposedgays\supabase\functions.sql", "r", encoding="utf-8") as f: sql = f.read() sftp = c.open_sftp() with sftp.file("/tmp/eg_functions.sql", "w") as remote: remote.write(sql) sftp.close() run("cat /tmp/eg_functions.sql | docker exec -i supabase-db psql -U postgres -d postgres 2>&1 | tail -20") # Ensure privacy columns exist run( "docker exec -i supabase-db psql -U postgres -d postgres -c " "\"ALTER TABLE profiles ADD COLUMN IF NOT EXISTS height_in integer, " "ADD COLUMN IF NOT EXISTS weight_lb integer, " "ADD COLUMN IF NOT EXISTS body_type text, " "ADD COLUMN IF NOT EXISTS community text, " "ADD COLUMN IF NOT EXISTS seeking text;\" 2>&1" ) c.close() print("Done.")