kidpro2002 commited on
Commit
c8fb4f1
·
1 Parent(s): 68b9450

Fix quality_score column missing from leads table

Browse files
lead_gen_pro/l3_execution/database_doe.py CHANGED
@@ -82,6 +82,7 @@ def init_db() -> None:
82
  whatsapp_sent BOOLEAN DEFAULT 0,
83
  whatsapp_sent_at TIMESTAMP,
84
  whatsapp_link TEXT,
 
85
  email_sent BOOLEAN DEFAULT 0,
86
  email_sent_at TIMESTAMP,
87
  replied BOOLEAN DEFAULT 0,
@@ -141,6 +142,15 @@ def init_db() -> None:
141
  )
142
  """)
143
 
 
 
 
 
 
 
 
 
 
144
  # Create indexes
145
  cursor.execute("CREATE INDEX IF NOT EXISTS idx_leads_status ON leads(status)")
146
  cursor.execute("CREATE INDEX IF NOT EXISTS idx_leads_niche ON leads(niche)")
 
82
  whatsapp_sent BOOLEAN DEFAULT 0,
83
  whatsapp_sent_at TIMESTAMP,
84
  whatsapp_link TEXT,
85
+ quality_score INTEGER DEFAULT 0,
86
  email_sent BOOLEAN DEFAULT 0,
87
  email_sent_at TIMESTAMP,
88
  replied BOOLEAN DEFAULT 0,
 
142
  )
143
  """)
144
 
145
+ # Migrations
146
+ cursor.execute("PRAGMA table_info(leads)")
147
+ columns = [col[1] for col in cursor.fetchall()]
148
+ if 'quality_score' not in columns:
149
+ try:
150
+ cursor.execute("ALTER TABLE leads ADD COLUMN quality_score INTEGER DEFAULT 0")
151
+ except Exception as e:
152
+ print(f"[DB] Migration error (quality_score): {e}")
153
+
154
  # Create indexes
155
  cursor.execute("CREATE INDEX IF NOT EXISTS idx_leads_status ON leads(status)")
156
  cursor.execute("CREATE INDEX IF NOT EXISTS idx_leads_niche ON leads(niche)")