I'm sure you're quite aware of this approach and it's just a matter of getting around to it (... and of course, every db change is the Last
TM change that ever needs to be done...) but I saw someone mention they spent an hour working on medals only to have their work overwritten, and I just wanted to share how I've been avoiding overwriting the database with schema changes in my game.
var latest_db_version = 20200329
var db_version = db.fetch_assoc("select Use1024 from App limit 1")[0]['Use1024']
if db_version < latest_db_version:
if db_version < 20200204:
db.execute("""create table Impacts (
ImpactID INTEGER PRIMARY KEY AUTOINCREMENT,
GameID INTEGER,
SystemID INTEGER,
ContactType INTEGER,
NumImpacts INTEGER,
Strength INTEGER,
Xcor REAL,
Ycor REAL)""")
db.execute("alter table Population add column ThermalSig integer")
db.execute("alter table Population add column EMSig integer")
db.execute("update Population set ThermalSig = 0, EMSig = 0")
if db_version < 20200209:
# ... And so on. Lots more of these blocks
db.execute("update App set Use1024 = " + str(latest_db_version))
(I repurposed the App.Use1024 field since I need to be compatible with a raw import of Stevefire.mdb)
Edit: I'm realizing this suggestion is more geared toward whenever new content gets added... it's not a great way for dealing with bugs that are cropping up that are entangled in existing data. Kind of wish this would stop getting bumped.