-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatic Database Migration #129
Comments
I dislike 1., IMO this is the equivalent of a "just reboot windows"-bugfix. Right now I would favor 2 > 3 > 4 > 1. But this is just after 5 minutes of quick thinking. :) |
The problem with the update scripts is that you cannot easily automate the updates during a package upgrade. That basically means that automatic upgrades may break a running pyCA. For once, you do not know which database is used since you can configure mysql, postgres, … to be used as well. Also, you either need upgrade scripts for each version or need to build a lot of safeguards into the script which might lead to weird SQL magic. Although at the moment, the script would be relatively simple: ALTER TABLE recorded_event ADD title TEXT;
DROP TABLE upcoming_event;
DROP TABLE service_states; Alembic would work, but it would create some unnecessary overhead since we do not need to migrate anything but The idea with 4 was to export the relevant data from First, add a Second, write an {
"uid": "123",
"start": 1,
"end": 2,
"tracks": {
"presenter/source": "xy.mp4"
}
} If, on start-up, a migration is required, drop all tables, re-initialize the database and import the data from the JSON files. If, for example, a new field This is certainly slower than an SQL alter statement but should be no problem with the amount of data we are dealing with. It has the advantage that, if we modify the database, we only need to bump the database version and, only if we modify the data of recorded events, set a sensible default for the import. The nice thing about this is, that it even works for data migration (say we want to extract data from the field Please let me know if you think this is an insane idea… |
Ah, yes, did not notice that getting the version of the old database might be a problem. I've only ever packaged for Arch Linux, where it's possible to start actions depending on the old package versions while upgrading. But that can be different to the actual database as well with some weird edge cases. Your suggestion to always write out a JSON file on recording success sounds sensible. A nice side effect of this is that recordings are (once again) self-contained in their directories, making it possible to move them around (and maybe backup?) if someone really wants to do that. One point though is the condition when this file would be saved to disk - I would even go as far as saving it when starting a recording. This would ensure that even failed recordings are registered on a database migration. Otherwise you maybe would have a lot of dead files when upgrading a database that still had a lot of failed/unfinished recordings in it. |
With 2.2 we will change the database structure. That means that we need to re-create the database. That, in turn, means that we will lose data if we do no do anything about it.
This is definitely no problem for the status tables or the buffer, but it might be a problem for the finished recordings. Although we do not lose any real data since the recordings are still there and the metadata are in Opencast. Still, it would be convenient to keep that table.
Hence, the question what we want to do about it. Options are:
I would be ok with 1., I dislike 2., I think 3. is a lot of work and not worth the effort and finally, I like 4.
My idea about 4. would be to add a database version table, just containing a number. If the internal pyCA database version if different, we would export the
recorded_event
table as JSON, re-create the database and finally import the JSON again. This should be easier than a complete migration and we should be able to even import old data since we only need to interpret what information we have about a given event. If at some point one field becomes irrelevant, we can simply drop it. If there is a new one, we set it to null or generate a sensible default.Packages could also make use of this method on upgrades by calling the migration script.
Any thoughts?
The text was updated successfully, but these errors were encountered: