Completed the GTM engine setup:\n\n- Implemented 'Dual Opener' generation (Primary/Secondary) in ClassificationService.\n- Migrated DB to support two opener fields.\n- Updated API and Frontend to handle and display both openers.\n- Fixed bug creating duplicate website_scrape entries.\n- Hardened metric extraction by improving the LLM prompt and adding content length checks.
30 lines
889 B
Python
30 lines
889 B
Python
import sqlite3
|
|
import sys
|
|
|
|
DB_PATH = "/app/companies_v3_fixed_2.db"
|
|
|
|
def migrate():
|
|
try:
|
|
conn = sqlite3.connect(DB_PATH)
|
|
cursor = conn.cursor()
|
|
|
|
print(f"Checking schema in {DB_PATH}...")
|
|
cursor.execute("PRAGMA table_info(companies)")
|
|
columns = [row[1] for row in cursor.fetchall()]
|
|
|
|
if "ai_opener_secondary" in columns:
|
|
print("Column 'ai_opener_secondary' already exists. Skipping.")
|
|
else:
|
|
print("Adding column 'ai_opener_secondary' to 'companies' table...")
|
|
cursor.execute("ALTER TABLE companies ADD COLUMN ai_opener_secondary TEXT")
|
|
conn.commit()
|
|
print("✅ Migration successful.")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Migration failed: {e}")
|
|
finally:
|
|
if conn: conn.close()
|
|
|
|
if __name__ == "__main__":
|
|
migrate()
|