kin: KIN-UI-002 Исправить падающие тесты миграции (регрессия KIN-ARCH-003) в core/db.py
This commit is contained in:
parent
389b266bee
commit
ff69d24acc
7 changed files with 254 additions and 10 deletions
28
core/db.py
28
core/db.py
|
|
@ -371,6 +371,34 @@ def _migrate(conn: sqlite3.Connection):
|
|||
""")
|
||||
conn.commit()
|
||||
|
||||
# Migrate columns that must exist before table recreation (KIN-UI-002)
|
||||
# These columns are referenced in the INSERT SELECT below but were not added
|
||||
# by any prior ALTER TABLE in this chain — causing OperationalError on minimal schemas.
|
||||
if "tech_stack" not in proj_cols:
|
||||
conn.execute("ALTER TABLE projects ADD COLUMN tech_stack JSON DEFAULT NULL")
|
||||
conn.commit()
|
||||
|
||||
if "priority" not in proj_cols:
|
||||
conn.execute("ALTER TABLE projects ADD COLUMN priority INTEGER DEFAULT 5")
|
||||
conn.commit()
|
||||
|
||||
if "pm_prompt" not in proj_cols:
|
||||
conn.execute("ALTER TABLE projects ADD COLUMN pm_prompt TEXT DEFAULT NULL")
|
||||
conn.commit()
|
||||
|
||||
if "claude_md_path" not in proj_cols:
|
||||
conn.execute("ALTER TABLE projects ADD COLUMN claude_md_path TEXT DEFAULT NULL")
|
||||
conn.commit()
|
||||
|
||||
if "forgejo_repo" not in proj_cols:
|
||||
conn.execute("ALTER TABLE projects ADD COLUMN forgejo_repo TEXT DEFAULT NULL")
|
||||
conn.commit()
|
||||
|
||||
if "created_at" not in proj_cols:
|
||||
# SQLite ALTER TABLE does not allow non-constant defaults like CURRENT_TIMESTAMP
|
||||
conn.execute("ALTER TABLE projects ADD COLUMN created_at DATETIME DEFAULT NULL")
|
||||
conn.commit()
|
||||
|
||||
# Migrate projects.path from NOT NULL to nullable (KIN-ARCH-003)
|
||||
# SQLite doesn't support ALTER COLUMN, so we recreate the table.
|
||||
path_col_rows = conn.execute("PRAGMA table_info(projects)").fetchall()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue