How to run a post-update script?
#1
Is there an easy way to run a post-update script on my addon after I bump the version on my repo?  I'm migrating from .pkl files to a SQLite database and I need to run a script to convert the user's previous data to the new format the first time it's called.

My addon has 3 entrypoints (default program and 2 context menu items), so it would seem a bit excessive to check for the old format every time one of these scripts are called.  Any ideas?
Reply
#2
Migration of addon data is a PITA. What I do in Advanced Emulator Launcher is to have an entry in the addon settings that points to a function in the Python code (what you call an entry point) that takes care of the migration.

One advantage is that users can run the addon settings without running the addon itself (if they do before the migration is done the addon may crash all the time). Another advantage is that the upgrade is only done once, there are no checks or tests every time the addon is run. However, you can do more fancy stuff: for example, you can have a version number in the data you addon uses. When a new version of the addon that requires a migration is released, you can very quickly check that the version of the data corresponds to a previous version and must be upgraded, and display a text window telling the user to upgrade. This version test is very quick and can be done every time the addon is called and you avoid crashes.

The main disadvantage is that users must do the upgrade manually after installing a new version that requires migration, it cannot be automatised.
Reply

Logout Mark Read Team Forum Stats Members Help
How to run a post-update script?0