• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
UBports Robot Logo UBports Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

history.sqlite reconstruct threads

Scheduled Pinned Locked Moved Support
appmessagingsms
14 Posts 6 Posters 3.4k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      advocatux @free.rage
      last edited by 20 Jul 2017, 12:20

      @free.rage, I just did:

      adb push from_my_backup_directory/.local/share/history-service/history.sqlite /home/phablet/.local/share/history-service/

      and it's working fine. I have all the old messages and I send and receive without problem.

      You need to substitute "from_my_backup_directory" for whatever you need, obviously.

      F 1 Reply Last reply 20 Jul 2017, 12:28 Reply Quote 0
      • F Offline
        free.rage @advocatux
        last edited by 20 Jul 2017, 12:28

        @advocatux, that's obviously what I did first (with rsync instead of adb). But it is not working. May be My app messaging was not in the latest version when I migrated my device ? But I had no notifications...
        Well I don't know the reason why it was not working.

        A 1 Reply Last reply 20 Jul 2017, 15:00 Reply Quote 0
        • A Offline
          advocatux @free.rage
          last edited by 20 Jul 2017, 15:00

          @free.rage did you reboot the phone? Re-scan is a necessary step.

          F 1 Reply Last reply 20 Jul 2017, 16:08 Reply Quote 1
          • F Offline
            free.rage @advocatux
            last edited by 20 Jul 2017, 16:08

            @advocatux Yes, I noticed that the service history needs a reboot to take into account a new sqlite file.

            A 1 Reply Last reply 20 Jul 2017, 21:40 Reply Quote 0
            • A Offline
              advocatux @free.rage
              last edited by 20 Jul 2017, 21:40

              @free.rage πŸ‘

              1 Reply Last reply Reply Quote 0
              • F Offline
                free.rage
                last edited by 20 Jul 2017, 22:13

                Well, may be I was not clear from my previous message. I noticed that a reboot was necessary but my problem is still there. All my messages are in the file but not all threads are displayed.

                D A 2 Replies Last reply 21 Jul 2017, 05:55 Reply Quote 0
                • D Offline
                  doniks @free.rage
                  last edited by 21 Jul 2017, 05:55

                  @free.rage Just thinking out loud here: Can you see a difference in the database between the threads that you DO see in the app and the ones that you DONT see?

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    advocatux @free.rage
                    last edited by 21 Jul 2017, 12:51

                    @free.rage, oh sorry. I don't know what's happening with that file. Has you check out the file permissions?

                    B 1 Reply Last reply 6 Sept 2017, 13:56 Reply Quote 0
                    • B Offline
                      BadAngel @advocatux
                      last edited by 6 Sept 2017, 13:56

                      Hi !
                      I just manage to migrate my history.sqlite file from my BQ aquarius 4.5 (with latest ubuntu touch updates) to my Nexus 5 (with a fresh ubport install).
                      The "old" database is in version 12, the new one is in version 17. So some modifications must be applied.
                      In my case my fresh install IS fresh (I do not have any previous message on it => I drop tables)

                      BEFORE: make a copy of the original/old history AND a copy of the fresh installed history: thoose are located in ~/.local/share/history-service/ on each phone. If you don't know / success to make a copy please do not go further.

                      WARNING: this process will destroy any message on the "new" phone.

                      I think its OK for the legal warnings πŸ˜‰

                      Let's suppose we are on the new phone and we have copied the "old" database on the new phone in ~/.local/share/history-service_old/ (including attachements of course ;).

                      First, let update the database structure of the old DB:

                      sqlite3 ~/.local/share/history-service_old/history.sqlite
                      sqlite> update schema_version set version=17;
                      sqlite> ALTER TABLE threads ADD COLUMN chatType tinyint;
                      sqlite> update threads set chatType=1;
                      sqlite> ALTER TABLE thread_participants ADD COLUMN alias varchar(255);
                      sqlite> ALTER TABLE thread_participants ADD COLUMN state tinyint;
                      sqlite> ALTER TABLE thread_participants ADD COLUMN roles tinyint;
                      sqlite> update thread_participants set state=0;
                      sqlite> update thread_participants set roles=0;
                      sqlite> ALTER TABLE text_events ADD COLUMN informationType integer;
                      sqlite> update text_events set informationType=0;
                      Exit with "Ctrl+D"
                      

                      This last "update" will take some time depending on the number of messages you have ...

                      Now dump the data to an SQL file:

                      sqlite3 ~/.local/share/history-service_old/history.sqlite .dump > history.sqlite_old.sql
                      

                      Now let's clean the current ("fresh") database:

                      sqlite3 ~/.local/share/history-service/history.sqlite
                      sqlite> drop table threads;
                      sqlite> drop table thread_participants;
                      sqlite> drop table voice_events;
                      sqlite> drop table text_event_attachments;
                      sqlite> drop table text_events;
                      Exit with "Ctrl+D"
                      

                      Now let's insert thoose old data:

                      sqlite3 ~/.local/share/history-service/history.sqlite < history.sqlite_old.sql
                      mkdir -p ~/.local/share/history-service/attachments/
                      rsync -av ~/.local/share/history-service_old/attachments/ ~/.local/share/history-service/attachments/
                      

                      At last:

                      sudo reboot
                      

                      Hope this will help ... It worked for me πŸ™‚

                      H 1 Reply Last reply 6 Sept 2017, 16:35 Reply Quote 1
                      • H Offline
                        hans1977se @BadAngel
                        last edited by 6 Sept 2017, 16:35

                        @BadAngel Nice! πŸ™‚ This kind of code should run when the history service starts actually, I think. Whenever the stored version is different from the current version, just copy the stored version to a backup file and convert it to the current version in a new file.

                        B 1 Reply Last reply 6 Sept 2017, 18:35 Reply Quote 0
                        • B Offline
                          BadAngel @hans1977se
                          last edited by 6 Sept 2017, 18:35

                          @hans1977se Thanks ! I expected this to be automated πŸ˜‰
                          Copying databases for the contacts worked, but for the SMS the message application starts but seems to perform the DB migration for some seconds (maybe 30 seconds) then displays a screen "send your first message".
                          I think it is due to some timeout for the DB migration. The statement "update text_events set informationType=0;" took 2 or 3 minutes to complete on my telephone (I have a big amount of SMS / MMS). Maybe the automated DB migration works when you just have a small amount of messages ...

                          H 1 Reply Last reply 6 Sept 2017, 20:16 Reply Quote 0
                          • H Offline
                            hans1977se @BadAngel
                            last edited by 6 Sept 2017, 20:16

                            @BadAngel Hopefully it will be automated. A lot of good things happens in this project all the time. πŸ™‚

                            I have only migrated from the Canonical image to the stable ubports image, and there was no conversion needed for that. I think @Flohack might be on top of this and it would probably be very interesting if he has time to put down a few comments regarding this. πŸ™‚

                            1 Reply Last reply Reply Quote 0
                            • F Offline
                              flohack
                              last edited by 7 Sept 2017, 10:38

                              Hmm few comments: We did not change anything that I know that would make necessary these huge steps to get the db working again, I totally dont understand what happened here. Backup/Restore of my data worked when wiping several phones...

                              BR

                              My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

                              1 Reply Last reply Reply Quote 0
                              • KenedaK Keneda referenced this topic on 16 May 2022, 02:48
                              • First post
                                Last post