add scoped authenticated discovery and scraping

This commit is contained in:
Marco0300
2026-09-03 19:47:57 +02:00
parent 6b8ad8f419
commit 6269cdd6f1
4 changed files with 306 additions and 4 deletions
+13
View File
@@ -313,3 +313,16 @@ CREATE TABLE IF NOT EXISTS outreach_drafts (
);
CREATE INDEX IF NOT EXISTS idx_outreach_drafts_org ON outreach_drafts(organization_id,created_at DESC,id DESC);
CREATE INDEX IF NOT EXISTS idx_outreach_drafts_business ON outreach_drafts(organization_id,business_id,id DESC);
-- Built-in scoped discovery runs. Results are reviewable business records only;
-- this feature never sends outreach.
CREATE TABLE IF NOT EXISTS discovery_runs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
organization_id TEXT NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
job_id INTEGER NOT NULL REFERENCES jobs(id) ON DELETE CASCADE,
criteria_json TEXT NOT NULL DEFAULT '{}', seed_urls_json TEXT NOT NULL DEFAULT '[]',
result_json TEXT NOT NULL DEFAULT '{}', result_count INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE(organization_id,job_id)
);
CREATE INDEX IF NOT EXISTS idx_discovery_runs_org ON discovery_runs(organization_id,created_at DESC,id DESC);