Skip to content

Commit

Permalink
Add missing COMMIT after creating stats DB
Browse files Browse the repository at this point in the history
Each time when starting, the bot reads the `schema_version` table in `stats.db` and verifies that it's equal to the current schema version.

This is so that in the future we can have migration code that will convert users' databases from one schema to another.

If this table does not exist (or is empty) the bot will attempt to initialise the schema. Then, it writes the current schema version to the `schema_version` table.

Unfortunately, I forgot a `COMMIT` after that `INSERT` statement -- so the database transaction was still 'open' until another write was made (i.e. an encounter happened.)

If the user closed a new profile _before_ anything else was written, the `schema_version` table would remain empty and lead to an error message during the next start of that profile.
  • Loading branch information
hanzi committed Oct 3, 2024
1 parent 9bdd3b7 commit e31e96d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions modules/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,3 +1281,4 @@ def _update_schema(self, from_schema_version: int) -> None:

self._cursor.execute("DELETE FROM schema_version")
self._cursor.execute("INSERT INTO schema_version VALUES (?)", (current_schema_version,))
self._connection.commit()

0 comments on commit e31e96d

Please sign in to comment.