Properly update db

This commit is contained in:
cryptoguard 2025-03-26 23:17:02 -04:00
parent f66f857b35
commit b1eee8cc16

View file

@ -427,24 +427,7 @@ def upgradeDatabase(self, db_version):
)
elif current_version == 26:
db_version += 1
# First add the column
cursor.execute(
"ALTER TABLE offers ADD COLUMN auto_accept_type INTEGER NOT NULL DEFAULT 0"
)
# Then update existing rows based on auto_accept_bids
cursor.execute(
"""
UPDATE offers
SET auto_accept_type = CASE
WHEN auto_accept_bids = 1 THEN 1
ELSE 0
END
WHERE auto_accept_type IS NULL
"""
)
self.commitDB()
cursor.execute("ALTER TABLE offers ADD COLUMN auto_accept_type INTEGER")
if current_version != db_version:
self.db_version = db_version
self.setIntKV("db_version", db_version, cursor)