Fix TypeError when revision_count is stored as TEXT
The previous schema migration added revision_count as TEXT. SQLite stores the default as TEXT, but the app does integer arithmetic on it, causing: TypeError: unsupported operand type(s) for -: 'int' and 'str' - init_db() now adds revision_count as INTEGER. - app.py casts revision_count to int in play() and revise() and when incrementing in revise(), so existing TEXT values also work. Bump version 0.4.2 -> 0.4.3.
This commit is contained in:
parent
f5d3d487af
commit
4b48e0a44f
4 changed files with 8 additions and 7 deletions
|
|
@ -117,8 +117,9 @@ def init_db():
|
|||
existing = {r['name'] for r in db.execute(f"PRAGMA table_info({table})")}
|
||||
for col in columns:
|
||||
if col not in existing:
|
||||
# Use a safe default type; NULLable for all current optional columns.
|
||||
db.execute(f'ALTER TABLE {table} ADD COLUMN {col} TEXT')
|
||||
# revision_count must be INTEGER so arithmetic in app.py works.
|
||||
col_type = 'INTEGER' if col == 'revision_count' else 'TEXT'
|
||||
db.execute(f'ALTER TABLE {table} ADD COLUMN {col} {col_type}')
|
||||
db.commit()
|
||||
db.close()
|
||||
|
||||
|
|
|
|||
Reference in a new issue