← back to Wallco Ai
follow-ups #2 + #3: settlement trigger on all_designs (post-convergence) + retire MAX(id)+1 minting in heal-seam-region
05e0e019fe448cf2c7d89ca73ac124949fa592b6 · 2026-06-01 19:57:40 -0700 · Steve Abrams
- settlement_publish_check/insert_check now target base table all_designs (spoon is a view); installed live on prod (verified: blocks Part-A+B publish, passes clean)
- heal-seam-region.py: mint via sequence (RETURNING id) then set image_url from the real id, not a MAX(id)+1 prediction
Files touched
M scripts/heal-seam-region.pyM sql/settlement_publish_trigger.sql
Diff
commit 05e0e019fe448cf2c7d89ca73ac124949fa592b6
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon Jun 1 19:57:40 2026 -0700
follow-ups #2 + #3: settlement trigger on all_designs (post-convergence) + retire MAX(id)+1 minting in heal-seam-region
- settlement_publish_check/insert_check now target base table all_designs (spoon is a view); installed live on prod (verified: blocks Part-A+B publish, passes clean)
- heal-seam-region.py: mint via sequence (RETURNING id) then set image_url from the real id, not a MAX(id)+1 prediction
---
scripts/heal-seam-region.py | 10 ++++++++--
sql/settlement_publish_trigger.sql | 12 ++++++++----
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/scripts/heal-seam-region.py b/scripts/heal-seam-region.py
index 7707423..1b9a749 100644
--- a/scripts/heal-seam-region.py
+++ b/scripts/heal-seam-region.py
@@ -140,14 +140,20 @@ def main():
new_path = str(Path(src_path).parent / new_filename)
Image.fromarray(arr).save(new_path, optimize=True)
+ # Mint via the sequence — let id default to nextval and read it back with
+ # RETURNING. The old code baked image_url='/designs/img/by-id/'||(MAX(id)+1),
+ # which was WRONG whenever the sequence was ahead of or behind max(id) (it
+ # pointed image_url at a different id's by-id path). image_url is deterministic
+ # from the row's own id, so set it in a second step from the real id.
new_id = int(psql(
- "INSERT INTO all_designs (category, kind, prompt, negative_prompt, local_path, image_url, "
+ "INSERT INTO all_designs (category, kind, prompt, negative_prompt, local_path, "
" dominant_hex, width_in, height_in, seed, tags, is_published, user_removed, web_viewer, generator, source_dw_sku) "
- f"SELECT category, kind, prompt, negative_prompt, '{new_path}', '/designs/img/by-id/' || (SELECT COALESCE(MAX(id),0)+1 FROM all_designs), "
+ f"SELECT category, kind, prompt, negative_prompt, '{new_path}', "
f" dominant_hex, width_in, height_in, seed, (COALESCE(tags, ARRAY[]::text[])) || ARRAY['healed-from-{args.id}','seam-healed']::text[], "
f" FALSE, FALSE, FALSE, 'heal-seam-region', source_dw_sku "
f"FROM all_designs WHERE id={args.id} RETURNING id;"
))
+ psql(f"UPDATE all_designs SET image_url='/designs/img/by-id/' || id WHERE id={new_id};")
# 5. Re-scan the new id
scan_after = seam.scan_path(Path(new_path))
diff --git a/sql/settlement_publish_trigger.sql b/sql/settlement_publish_trigger.sql
index 8eaa85c..7c04dd8 100644
--- a/sql/settlement_publish_trigger.sql
+++ b/sql/settlement_publish_trigger.sql
@@ -101,16 +101,20 @@ BEGIN
END;
$$ LANGUAGE plpgsql;
-DROP TRIGGER IF EXISTS settlement_publish_check ON spoon_all_designs;
+-- Triggers attach to the BASE TABLE all_designs (NOT spoon_all_designs, which is
+-- now a VIEW over all_designs on both Mac2 and prod after the 2026-06-01
+-- convergence — a view can't carry BEFORE INSERT/UPDATE triggers). Writes via the
+-- updatable view land in all_designs, so the gate fires regardless of write path.
+DROP TRIGGER IF EXISTS settlement_publish_check ON all_designs;
CREATE TRIGGER settlement_publish_check
- BEFORE UPDATE OF is_published ON spoon_all_designs
+ BEFORE UPDATE OF is_published ON all_designs
FOR EACH ROW
EXECUTE FUNCTION settlement_publish_check();
-- Also fire on INSERT for any row that comes in with is_published=true.
-DROP TRIGGER IF EXISTS settlement_insert_check ON spoon_all_designs;
+DROP TRIGGER IF EXISTS settlement_insert_check ON all_designs;
CREATE TRIGGER settlement_insert_check
- BEFORE INSERT ON spoon_all_designs
+ BEFORE INSERT ON all_designs
FOR EACH ROW
WHEN (NEW.is_published IS TRUE)
EXECUTE FUNCTION settlement_publish_check();
← 08fb7a1 PDP theme switcher: working public dropdown (Classic + 17 va
·
back to Wallco Ai
·
follow-up #1 (two-master, /dtd Option B): disjoint id ranges f78404f →