From 870aa90c005f77a73445f5c39f9fd9bbb7604fe8 Mon Sep 17 00:00:00 2001
From: Dan Goodliffe <dan@randomdan.homeip.net>
Date: Sat, 4 Jul 2026 20:19:34 +0100
Subject: Insert uninsirtable lines using the hostnameId recorded in the
 bad_lines table

Includes the same fix from the previous commit which stops caching
entities until the inserts are complete.
Updates storeLogLine to take an insert command with the hostnameId
already bound.
---
 src/schema.sql | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'src/schema.sql')

diff --git a/src/schema.sql b/src/schema.sql
index 40cab51..fd2f3c5 100644
--- a/src/schema.sql
+++ b/src/schema.sql
@@ -94,6 +94,9 @@ CREATE INDEX idx_entities_retryinsert ON bad_lines(id)
 WHERE
 	type = 'uninsertable_line' AND detail ->> 'retriedAt' IS NULL;
 
+ALTER TABLE bad_lines
+	ADD CONSTRAINT bad_lines_have_hostnameid CHECK (detail ? 'hostnameId');
+
 CREATE OR REPLACE FUNCTION entity(newValue text, newType entity)
 	RETURNS TABLE(
 		id integer,
-- 
cgit v1.3

