fix: Restore previous DB, migrate schema, mount Notion token
This commit is contained in:
@@ -14,7 +14,7 @@ try:
|
|||||||
DEBUG: bool = True
|
DEBUG: bool = True
|
||||||
|
|
||||||
# Database (Store in App dir for simplicity)
|
# Database (Store in App dir for simplicity)
|
||||||
DATABASE_URL: str = "sqlite:////app/companies_v4_notion_sync.db"
|
DATABASE_URL: str = "sqlite:////app/companies_v3_fixed_2.db"
|
||||||
|
|
||||||
# API Keys
|
# API Keys
|
||||||
GEMINI_API_KEY: Optional[str] = None
|
GEMINI_API_KEY: Optional[str] = None
|
||||||
|
|||||||
49
company-explorer/backend/scripts/migrate_v3_to_v4.py
Normal file
49
company-explorer/backend/scripts/migrate_v3_to_v4.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import sqlite3
|
||||||
|
import os
|
||||||
|
|
||||||
|
# DB Path relative to this script
|
||||||
|
# script is in company-explorer/backend/scripts/
|
||||||
|
# DB is in company-explorer/companies_v3_fixed_2.db
|
||||||
|
DB_PATH = os.path.join(os.path.dirname(__file__), "../../companies_v3_fixed_2.db")
|
||||||
|
|
||||||
|
def add_column(cursor, table, column, type_def):
|
||||||
|
try:
|
||||||
|
print(f"Adding column {column} to {table}...")
|
||||||
|
cursor.execute(f"ALTER TABLE {table} ADD COLUMN {column} {type_def}")
|
||||||
|
print("Done.")
|
||||||
|
except sqlite3.OperationalError as e:
|
||||||
|
if "duplicate column name" in str(e):
|
||||||
|
print(f"Column {column} already exists.")
|
||||||
|
else:
|
||||||
|
print(f"Error: {e}")
|
||||||
|
|
||||||
|
def migrate():
|
||||||
|
if not os.path.exists(DB_PATH):
|
||||||
|
print(f"Database not found at {DB_PATH}")
|
||||||
|
return
|
||||||
|
|
||||||
|
conn = sqlite3.connect(DB_PATH)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
# Industries columns
|
||||||
|
add_column(cursor, "industries", "notion_id", "TEXT")
|
||||||
|
add_column(cursor, "industries", "industry_group", "TEXT")
|
||||||
|
add_column(cursor, "industries", "status_notion", "TEXT")
|
||||||
|
add_column(cursor, "industries", "whale_threshold", "REAL")
|
||||||
|
add_column(cursor, "industries", "min_requirement", "REAL")
|
||||||
|
add_column(cursor, "industries", "scraper_keywords", "TEXT")
|
||||||
|
add_column(cursor, "industries", "core_unit", "TEXT")
|
||||||
|
add_column(cursor, "industries", "proxy_factor", "TEXT")
|
||||||
|
|
||||||
|
# Robotics Categories columns
|
||||||
|
add_column(cursor, "robotics_categories", "notion_id", "TEXT")
|
||||||
|
|
||||||
|
# Enrichment Data columns (just in case)
|
||||||
|
add_column(cursor, "enrichment_data", "wiki_verified_empty", "BOOLEAN DEFAULT 0")
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
print("Migration completed.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
migrate()
|
||||||
@@ -40,6 +40,7 @@ services:
|
|||||||
# Keys
|
# Keys
|
||||||
- ./gemini_api_key.txt:/app/gemini_api_key.txt
|
- ./gemini_api_key.txt:/app/gemini_api_key.txt
|
||||||
- ./serpapikey.txt:/app/serpapikey.txt
|
- ./serpapikey.txt:/app/serpapikey.txt
|
||||||
|
- ./notion_token.txt:/app/notion_token.txt
|
||||||
# Logs (Debug)
|
# Logs (Debug)
|
||||||
- ./Log_from_docker:/app/logs_debug
|
- ./Log_from_docker:/app/logs_debug
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
Reference in New Issue
Block a user