Well, good news. The script is pretty much done (videos only for now). I have to finalize, test and make it work with upgrading the DB and adding new clients (right now this is all pretty static).
So the way it works, for those interested, is that it looks at all the tables in the main database and then replicates everything with a view instead of a real table. it adds 2 columns to the main `files` table and moves it to globalfiles. It then creates a view for `files` in the main database. I wasn't sure if that was needed, but whatever, I followed the sql from timmyj9's post.
After this, it cycles through all the tables and creates the same ones on the client db. It reads all the columns from each table and links them in the client db.
The views are a pain in the ass, but I've managed to make them dynamic as well. I read the SHOW CREATE from the views and modify only what I need, pretty much like timmyj9's except if the views changes, if there are new views added in the future, this will also take care of them. I went into this with the thought that whenever the revision of the db increases its because there was a change to the schema.
So, the path to upgrade will be: compile new source, start kodi on main db, run the script.
The last step needed in the script is what happens when the db upgrades. I need to read the old column from the previous db, copy it over to the new one. This shouldn't take me that lon as it is far simpler than what I've done so far.
Here's the work so far:
This should work in its current form, but if someone wants to chime in and try to make it better, please do!
I plan on adding command line to configure the top part of the script.