feat: add digest_queue table to schema and dev-api startup
This commit is contained in:
parent
11a8441fed
commit
b56ad40c9e
2 changed files with 26 additions and 0 deletions
16
dev-api.py
16
dev-api.py
|
|
@ -53,6 +53,22 @@ def _strip_html(text: str | None) -> str | None:
|
|||
return cleaned.strip() or None
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
def _startup():
|
||||
"""Ensure digest_queue table exists (dev-api may run against an existing DB)."""
|
||||
db = _get_db()
|
||||
db.execute("""
|
||||
CREATE TABLE IF NOT EXISTS digest_queue (
|
||||
id INTEGER PRIMARY KEY,
|
||||
job_contact_id INTEGER NOT NULL REFERENCES job_contacts(id),
|
||||
created_at TEXT DEFAULT (datetime('now')),
|
||||
UNIQUE(job_contact_id)
|
||||
)
|
||||
""")
|
||||
db.commit()
|
||||
db.close()
|
||||
|
||||
|
||||
def _row_to_job(row) -> dict:
|
||||
d = dict(row)
|
||||
d["is_remote"] = bool(d.get("is_remote", 0))
|
||||
|
|
|
|||
|
|
@ -137,6 +137,15 @@ CREATE TABLE IF NOT EXISTS survey_responses (
|
|||
);
|
||||
"""
|
||||
|
||||
CREATE_DIGEST_QUEUE = """
|
||||
CREATE TABLE IF NOT EXISTS digest_queue (
|
||||
id INTEGER PRIMARY KEY,
|
||||
job_contact_id INTEGER NOT NULL REFERENCES job_contacts(id),
|
||||
created_at TEXT DEFAULT (datetime('now')),
|
||||
UNIQUE(job_contact_id)
|
||||
)
|
||||
"""
|
||||
|
||||
_MIGRATIONS = [
|
||||
("cover_letter", "TEXT"),
|
||||
("applied_at", "TEXT"),
|
||||
|
|
@ -193,6 +202,7 @@ def init_db(db_path: Path = DEFAULT_DB) -> None:
|
|||
conn.execute(CREATE_COMPANY_RESEARCH)
|
||||
conn.execute(CREATE_BACKGROUND_TASKS)
|
||||
conn.execute(CREATE_SURVEY_RESPONSES)
|
||||
conn.execute(CREATE_DIGEST_QUEUE)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
_migrate_db(db_path)
|
||||
|
|
|
|||
Loading…
Reference in a new issue