Files
Brancheneinstufung2/company-explorer/upgrade_schema.py

40 lines
1.1 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import sqlite3
import os
DB_PATH = "/app/companies_v3_fixed_2.db"
# If running outside container, adjust path
if not os.path.exists(DB_PATH):
DB_PATH = "companies_v3_fixed_2.db"
def upgrade():
print(f"Upgrading database at {DB_PATH}...")
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
# 2. Add Columns to Contact
try:
cursor.execute("ALTER TABLE contacts ADD COLUMN so_contact_id INTEGER")
print("✅ Added column: so_contact_id")
except sqlite3.OperationalError as e:
if "duplicate column" in str(e):
print(" Column so_contact_id already exists")
else:
print(f"❌ Error adding so_contact_id: {e}")
try:
cursor.execute("ALTER TABLE contacts ADD COLUMN so_person_id INTEGER")
print("✅ Added column: so_person_id")
except sqlite3.OperationalError as e:
if "duplicate column" in str(e):
print(" Column so_person_id already exists")
else:
print(f"❌ Error adding so_person_id: {e}")
conn.commit()
conn.close()
print("Upgrade complete.")
if __name__ == "__main__":
upgrade()