fix: restore profile verification schema

This commit is contained in:
2026-08-26 15:57:53 +03:00
parent b527791a10
commit 4a4b1d89e3
11 changed files with 94 additions and 10 deletions

View File

@@ -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")}