fix: restore profile verification schema
This commit is contained in:
14
app/db.py
14
app/db.py
@@ -41,6 +41,20 @@ def _ensure_runtime_schema() -> None:
|
||||
models.EmployeeNewsLink.__table__.create(bind=engine, checkfirst=True)
|
||||
inspector = inspect(engine)
|
||||
table_names = set(inspector.get_table_names())
|
||||
if "employees" in table_names and "employee_profile_urls" not in table_names:
|
||||
models.EmployeeProfileUrl.__table__.create(bind=engine, checkfirst=True)
|
||||
inspector = inspect(engine)
|
||||
if "employees" in table_names:
|
||||
employee_columns = {column["name"] for column in inspector.get_columns("employees")}
|
||||
missing_columns = []
|
||||
if "profile_unavailable_streak" not in employee_columns:
|
||||
missing_columns.append("profile_unavailable_streak INTEGER NOT NULL DEFAULT 0")
|
||||
if "last_profile_check_at" not in employee_columns:
|
||||
missing_columns.append("last_profile_check_at TIMESTAMPTZ")
|
||||
if missing_columns:
|
||||
with engine.begin() as connection:
|
||||
for column in missing_columns:
|
||||
connection.execute(text(f"ALTER TABLE employees ADD COLUMN {column}"))
|
||||
if "crawl_runs" not in table_names:
|
||||
return
|
||||
crawl_run_columns = {column["name"] for column in inspector.get_columns("crawl_runs")}
|
||||
|
||||
Reference in New Issue
Block a user