-
Notifications
You must be signed in to change notification settings - Fork 3
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
Tool not working since mid july due to changes in database schema #5
Comments
Hi! I am not able to spend time on this but if you plan to work on it, I can give you some pointers. |
Hi I can spend some time on this but I am really out of my depth in knowing any kotlin or anything of that sort. I would be happy to get any pointers from you. I will start off with what I think I can do then some questions, I recognise the names in the schema.kt and I believe this list all the cross-talk ids you check for and the tables they reside in. I think I will be able to update this to the October Schema since I recognise them.
I am not sure if the need would arise but I feel like it is possible, can I add more id/table pairs in this section and it will sync those up as well? I think you already have all the various ids that may be required at least once somewhere in there. Do you also update and offset the jid in addition to the id in messages? I cannot identify in my lack of knowledge where it does the offsets and figures out what ids need to be synchronised. My best guess is that the schema.kt files defines the relationships and the code goes off this to then do the right offset and syncing with each id/table pair listed there. A more general question is: does the tool assume the schema/format of the database to be the same for both db files and that the order of which file is newer or older does not matter? |
Hi! Schema class has an object called Schema { You can start by making october identical to march, then make your modifications. All tables that you add (
All of these are important. Everything that's either an ID or a reference will be updated, the rest just copied.
As you test remember to update Main.kt to use Schema.October2022 instead of March2022. Ideally we want a command line option here, use the other options as a reference |
Gotcha thank you very much for the explanations. They are very helpful.
Yeap yours makes it the easiest to tell it which ids refer to where etc and let it do it's job. I will probably work on this since my database is a bit messy and this would be less hacky.
Yeah I thought this would be the case. A conversion utility would definitely be way beyond me (and I imagine a nightmare to support with needing options and even a way to find what version it is) haha I was minimally hoping maybe your may be close to have the ability to select the versions.
Righto, I most likely wont be able to do this unless you have some code in there i can reverse engineer. Even then probably need a breather to look at it another day Again thanks for your support, should be able to get it working again. Once I update it and submit a pull, would it auto build a release? Or will I need to figure that part out as well? |
Yeah, when you do
When you merge dbs all IDs might change. Imagine I have a message with id 200 with a selfRef at column
You will make the changes locally and test them on your machine. Once you know it worked, you can open the PR and we can check how to release for other people later. |
Hi again, I have encountered a problem while trying to build with the new schema. I am getting the error I tried to use the below to just load the ids for Any suggestions for this? I dont have the slightest idea where I can potential change. Also 2 questions: |
@MrBarbie I updated code to enable circular references in tables. You can now do, for example: val xxx: Table by table(hasId = true, refs = listOf(Table.Ref("zzz", { yyy })))
val yyy: Table by table(hasId = true, refs = listOf(Table.Ref("zzz", { xxx }))) The timestamp column has no purpose for now, but it would be nice if you add it. I wanted to support a feature like "delete all database entries between March 3rd 2021 and April 20th 2022". Knowing which column represents time, will allow this.
I don't remember. They gave some errors on my own databases, so I disabled consistency checks for them. |
@natario1 Great thanks for updating it. Still getting complied failures though
I have submitted a pull request incase it might help you troubleshoot. I have updated the schema to have at least all current tables correct. May add more at a later date if it runs again. But at the moment this error is deep into kotlin territory of which I am no help. |
Ok! So the code in your PR is the one that does not compile? Or did you remove the problematic lines? |
It is the one that does not compile |
Ok, I fixed it for you |
Oh thanks! Damn it I thought it might have been that specific formatting but I applied to both and still got the same error. Shows my complete inexperience with kotlin XD |
@natario1 Ok managed to run it and found a whole bunch of inconsistencies which I think is what you found last time. Most of these are because of a weird line at the top of all my I think it was near the end as it already got to Could this be because you havent implemented mapping for selfRefs? Cause message does have a selfRef |
Do you think something like below could work in Main.kt (around line 117)? If I put |
It looks like this part of the code is not able to deal with circular references (e.g. chat table references messages, which references chat). It can deal with self references, which is the shortest circular possible reference. But not more complex ones like those you have introduced. I'm not sure how to fix it. There should probably be two passes, e.g. transform what we have now: schema.forEach {
...
processReferences(selfReferences = false)
computeIdMapping(...)
applyIdMapping(...)
processReferences(selfReferences = true)
} Into something like: schema.forEach {
processReferencesForWhichWeHaveAMapping()
computeIdMapping(...)
applyIdMapping(...)
}
schema.forEach {
processReferencesThatWeCouldNotProcessBeforeNowThatAllMappingsHaveBeenComputed()
} Basically, the whole |
Gotcha on the selfReferences. I am not sure what the difference between the non-self mapping with the selfRef mapping is but the non-self one I introduced here causes it to just outright stop when it fails so we wont be able to get into the second round. The problem with this
Is that for the first part we basically only have Can we only computeIdMapping for the schema.forEach {\\for just `jid`
processReferencesFor`jid`WhichWeHaveAMapping()
computeIdMapping(...) \\ do it for `chat` and `message` during `jid`
applyIdMapping(...)
}
schema.forEach { \\for everything else
processReferencesThatWeCouldNotProcessBeforeNowThatAllMappingsHaveBeenComputed()
computeIdMapping(...)
applyIdMapping(...)
} Does it not work because you have to process it first to be able to compute the mapping? If so, is the best way to restrict the schema.forEach to certain subsets of tables through using another |
Ok I hacked together something that compiles and runs and claims it has suceeded. But still veryfing it at the moment. |
Alright, I believe I have got a version working now. It may not be a pretty solution (no special tags or anything and may require/impossible manual fixing if schema changes too much again) but that is the limit of what I can do. Anything that goes any layer deeper I cannot understand it enough to edit (probably some specific limitations I am unware of and the full options of the syntax to know what each line is doing exactly). What I did in the end is
|
so how to build/compile this October update to be runnable application? |
Do you know how to build kotlin? I followed guides for building kotlin with gradle. I have uploaded an intial version in the fork as well |
Hi thanks for this. Gonna try it.
By this did u mean the zip in your fork? In this link. |
Seems like in version 2.22.7.74 the schema changed a lot, most likely to this feature of being able to switch between iOS and Android more seamlessly.
This cool author blogpost has some info to get started with the changes, the TLDR is that the messages (plural) tables have been dropped and now they are called message and message_* and there are a few more.
https://thebinaryhick.blog/2022/06/09/new-msgstore-who-dis-a-look-at-an-updated-whatsapp-on-android/
Do you think you could find some time to update the tool? Ideally it would detect the version and would be able to merge both and migrate to the new schema for the output database.
I'm very interested in this so if you say that you won't be able to look at it anytime soon I might try to give it a chance but I'm new to Kotlin, only being able to run the project in IntelliJ took me an hour LOL.
Thanks in any case for this contribution!
The text was updated successfully, but these errors were encountered: